Various numeral systems

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: Binary number

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("b.10101 + B.10101");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.5.0.0] Res: b.10101 + B.10101 = 42.0

Case 2: Octal number

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("o.120 + O.120");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.5.0.0] Res: o.120 + O.120 = 160.0

Case 3: Hexadecimal number

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("h.2FE + H.2fE");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.5.0.0] Res: h.2FE + H.2fE = 1532.0

Case 4: Unary number

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("b1.111 + B1.111");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.5.0.0] Res: b1.111 + B1.111 = 6.0

Case 5: Unary zero

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

Case 6: Base 1 – 36 number literals

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("b1.1 + b2.101 + b3.102 + b8.71 + b10.12340 + b11.12340A + b16.FF + b25.fgh + b36.xYZ");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.5.0.0] Res: b1.1 + b2.101 + b3.102 + b8.71 + b10.12340 + b11.12340A + b16.FF + b25.fgh + b36.xYZ = 261308.0

Case 7: Base N numeral system

import org.mariuszgromada.math.mxparser.*;
...
Expression e = new Expression("base(1, 1, 1, 1) + base(2, 1, 0, 1) + base(10, 1, 2, 3, 9) + base(16, 0, 1, 15) + base(50, 1, 2, 3, 49)");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.5.0.0] Res: base(1, 1, 1, 1) + base(2, 1, 0, 1) + base(10, 1, 2, 3, 9) + base(16, 0, 1, 15) + base(50, 1, 2, 3, 49) = 131477.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
Source code .zipSource code .tar.gz
View on GitHubMathSpace.pl

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