Various numeral systems

mXparser - logo

Did you find the software useful? Please consider donation 🙂
Developing and maintaining MathParser.org-mXparser takes a lot of time, mainly my free time. I hope it saved some of your time. If yes, then buy me a coffee 🙂
DONATE

JAVA code

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.4.1.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.4.1.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.4.1.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.4.1.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.4.1.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.4.1.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.4.1.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

*** If you found the software useful donation is something you might consider 🙂 ***

If you found the software useful donation is something you might consider :-)

Enjoy! 🙂

 

Best regards,

Mariusz Gromada

Download latest release – v.4.1.1 Aeries: bin + doc + src (.zip 13.4 MB)

Download latest release – v.4.1.1 Aeries: bin only (.zip 4.35 MB) – separate binaries for java: 1.5, 1.6, 1.7, 1.8; .NET: 2.0, 3.0, 3.5, 4.0, 4.5, 4.6, 4.7, .NET Core, .NET Standard, .NET PCL, Xamarin.Android, Xamarin.iOS

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