Bitwise Operators

TO SUPPORT MY WORK, ORDER A COMMERCIAL LICENSE
THANK YOU!

Tutorial Math Collection API spec Download

Below is the code for JAVA, the code for C# is almost identical.

Case 1: Bitwise unary complement

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("@~2");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate() );
[mXparser-v.5.0.0] Res: @~2 = -3.0

Case 2: Bitwise AND

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("10 @& 2");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate() );
[mXparser-v.5.0.0] Res: 10 @& 2 = 2.0

Case 3: Bitwise exclusive OR

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("10 @^ 2");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate() );
[mXparser-v.5.0.0] Res: 10 @^ 2 = 8.0

Case 4: Bitwise inclusive OR

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("10 @| 2");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate() );
[mXparser-v.5.0.0] Res: 10 @| 2 = 10.0

Case 5: Signed left / right shift

import org.mariuszgromada.math.mxparser.*;
...
/*
 * Left shift
 */
Expression e1 = new Expression("10 @<< 2");
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + e1.calculate() );
/*
 * Right shift
 */
Expression e2 = new Expression("10 @>> 2");
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + e2.calculate() );
[mXparser-v.5.0.0] Res 1: 10 @<< 2 = 40.0
&#91;mXparser-v.5.0.0&#93; Res 2: 10 @>> 2 = 2.0
Nuget
Install-Package MathParser.org-mXparser -Version 5.0.2
Maven
<dependency>
<groupid>org.mariuszgromada.math</groupid>
<artifactid>MathParser.org-mXparser</artifactid>
<version>5.0.2</version>
</dependency>
Gradle
implementation 'org.mariuszgromada.math:MathParser.org-mXparser:5.0.2'
Gradle (Kotlin)
implementation("org.mariuszgromada.math:MathParser.org-mXparser:5.0.2")
GitHub
git clone https://github.com/mariuszgromada/MathParser.org-mXparser
OTHER DOWNLOAD OPTIONS

Download latest release – v.5.0.2 Leonis: bin + docDownload latest release – v.5.0.2 Leonis: bin only, includes separate binaries for various .NET platforms and Java versions

NEWS FROM MATHPARSER.ORG
SOURCE CODE

Source code .zipSource code .tar.gz
View on GitHubMathSpace.pl

DONATION
Did you find the software useful?
Please consider donation 🙂
DONATE