GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing mathparser.org — Bitwise Operators - mXparser - Math Expressions Parser for JAVA, C#, C++, Kotlin, Android, .NET/MONO/Xamarin - Mathematical Formula Parser / Evaluator Library FOR COMMERCIAL USE, PLEASE ENSURE YOU HAVE A COMMERCIAL LICENSE.ANOTHER WAY TO SUPPORT MY WORK IS BY PURCHASING MY BOOK, CUSTOMER FIRST, VALUE NEXT.THANK YOU FOR SUPPORTING MY WORK!The tutorial consists of more than 200 live examples from 50 sections given separately for JAVA, C# and C++. Each of the examples can be copied and run on your own environment. In addition, mXparser provides an extensive collection of over 500 built-in math functions, expressions and symbols. Familiarize yourself with the scope and the syntax. Live testing is the best way to learn. Good luck! 🙂Tutorial Math Collection API spec Download Below is the code for JAVA, C# (the code for C# is almost identical) and C++. To copy the code, double-click inside the frame.Case 1: Bitwise unary complementJava/C# code// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e1 = new Expression("@~ 2");
Expression e2 = new Expression("@~ b.10");
double v1 = e1.calculate();
double v2 = e2.calculate();
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + v1 );
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + v2 + ", bits = " + mXparser.convDecimal2OthBase(v2, 2));
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e1 = new_Expression("@~ 2");
ExpressionPtr e2 = new_Expression("@~ b.10");
double v1 = e1->calculate();
double v2 = e2->calculate();
mXparser::consolePrintln("Res 1: " + e1->getExpressionString() + " = " + v1 );
mXparser::consolePrintln("Res 2: " + e2->getExpressionString() + " = " + v2 + ", bits = " + mXparser::convDecimal2OthBase(v2, 2));
Code result[mXparser-v.5.2.1] Res 1: @~ 2 = -3.0 [mXparser-v.5.2.1] Res 2: @~ b.10 = -3.0, bits = -11 Case 2: Bitwise ANDJava/C# code// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e1 = new Expression("13 @& 10");
Expression e2 = new Expression("b.1101 @& b.1010");
double v1 = e1.calculate();
double v2 = e2.calculate();
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + v1 );
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + v2 + ", bits = " + mXparser.convDecimal2OthBase(v2, 2));
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e1 = new_Expression("13 @& 10");
ExpressionPtr e2 = new_Expression("b.1101 @& b.1010");
double v1 = e1->calculate();
double v2 = e2->calculate();
mXparser::consolePrintln("Res 1: " + e1->getExpressionString() + " = " + v1 );
mXparser::consolePrintln("Res 2: " + e2->getExpressionString() + " = " + v2 + ", bits = " + mXparser::convDecimal2OthBase(v2, 2));
Code result[mXparser-v.5.2.1] Res 1: 13 @& 10 = 8.0 [mXparser-v.5.2.1] Res 2: b.1101 @& b.1010 = 8.0, bits = 1000 Case 3: Bitwise exclusive ORJava/C# code// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e1 = new Expression("13 @^ 10");
Expression e2 = new Expression("b.1101 @^ b.1010");
double v1 = e1.calculate();
double v2 = e2.calculate();
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + v1 );
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + v2 + ", bits = " + mXparser.convDecimal2OthBase(v2, 2));
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e1 = new_Expression("13 @^ 10");
ExpressionPtr e2 = new_Expression("b.1101 @^ b.1010");
double v1 = e1->calculate();
double v2 = e2->calculate();
mXparser::consolePrintln("Res 1: " + e1->getExpressionString() + " = " + v1 );
mXparser::consolePrintln("Res 2: " + e2->getExpressionString() + " = " + v2 + ", bits = " + mXparser::convDecimal2OthBase(v2, 2));
Code result[mXparser-v.5.2.1] Res 1: 13 @^ 10 = 7.0 [mXparser-v.5.2.1] Res 2: b.1101 @^ b.1010 = 7.0, bits = 111 Case 4: Bitwise inclusive ORJava/C# code// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e1 = new Expression("13 @| 10");
Expression e2 = new Expression("b.1101 @| b.1010");
double v1 = e1.calculate();
double v2 = e2.calculate();
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + v1 );
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + v2 + ", bits = " + mXparser.convDecimal2OthBase(v2, 2));
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e1 = new_Expression("13 @| 10");
ExpressionPtr e2 = new_Expression("b.1101 @| b.1010");
double v1 = e1->calculate();
double v2 = e2->calculate();
mXparser::consolePrintln("Res 1: " + e1->getExpressionString() + " = " + v1 );
mXparser::consolePrintln("Res 2: " + e2->getExpressionString() + " = " + v2 + ", bits = " + mXparser::convDecimal2OthBase(v2, 2));
Code result[mXparser-v.5.2.1] Res 1: 13 @| 10 = 15.0 [mXparser-v.5.2.1] Res 2: b.1101 @| b.1010 = 15.0, bits = 1111 Case 5: Signed left shiftJava/C# code// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e1 = new Expression("13 @<< 2");
Expression e2 = new Expression("b.1101 @<< b.10");
double v1 = e1.calculate();
double v2 = e2.calculate();
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + v1 );
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + v2 + ", bits = " + mXparser.convDecimal2OthBase(v2, 2));
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e1 = new_Expression("13 @<< 2");
ExpressionPtr e2 = new_Expression("b.1101 @<< b.10");
double v1 = e1->calculate();
double v2 = e2->calculate();
mXparser::consolePrintln("Res 1: " + e1->getExpressionString() + " = " + v1 );
mXparser::consolePrintln("Res 2: " + e2->getExpressionString() + " = " + v2 + ", bits = " + mXparser::convDecimal2OthBase(v2, 2));
Code result[mXparser-v.5.2.1] Res 1: 13 @<< 2 = 52.0 [mXparser-v.5.2.1] Res 2: b.1101 @<< b.10 = 52.0, bits = 110100 Case 6: Signed right shiftJava/C# code// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e1 = new Expression("13 @>> 2");
Expression e2 = new Expression("b.1101 @>> b.10");
double v1 = e1.calculate();
double v2 = e2.calculate();
mXparser.consolePrintln("Res 1: " + e1.getExpressionString() + " = " + v1 );
mXparser.consolePrintln("Res 2: " + e2.getExpressionString() + " = " + v2 + ", bits = " + mXparser.convDecimal2OthBase(v2, 2));
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e1 = new_Expression("13 @>> 2");
ExpressionPtr e2 = new_Expression("b.1101 @>> b.10");
double v1 = e1->calculate();
double v2 = e2->calculate();
mXparser::consolePrintln("Res 1: " + e1->getExpressionString() + " = " + v1 );
mXparser::consolePrintln("Res 2: " + e2->getExpressionString() + " = " + v2 + ", bits = " + mXparser::convDecimal2OthBase(v2, 2));
Code result[mXparser-v.5.2.1] Res 1: 13 @>> 2 = 3.0 [mXparser-v.5.2.1] Res 2: b.1101 @>> b.10 = 3.0, bits = 11 Case 7: Bitwise NAND, NOR, XOR (since v.6.0)Java/C# code// Getting help content as HTML table
String help = mXparser.getHelpAsHtmlTable("bitwise");
mXparser.consolePrintln(help);
C++ code#include "org/mariuszgromada/math/mxparser.hpp"
// ...
StringPtr help = mXparser::getHelpAsHtmlTable("bitwise");
mXparser::consolePrintln(help);
Code result
Nuget – Package Manager (C#, F#, Visual Basic, …)
Maven – Dependency (Java, Kotlin, Scala, Groovy, …)
Maven – Gradle
CMake – Dependency / FetchContent (C++, MSVC, LLVM/Clang, GNU/GCC, MinGW, MSYS2, WSL, Windows, Linux, Unix, MacOS)
GitHub
OTHER DOWNLOAD OPTIONSDownload latest release – v.6.1.0 Sagitara: .NET bin onlyDownload latest release – v.6.1.0 Sagitara: JAVA bin onlyDownload latest release – v.6.1.0 Sagitara: bin + doc NEWS FROM MATHPARSER.ORGSOURCE CODESource code .zipSource code .tar.gz My other creative spacesDONATIONDonation with PayPal | ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |