Math Parser: Java, C#, C++, Kotlin, Android, and all .NET platforms (Nuget, Maven, CMake). Supports .NET Framework, .NET Core, .NET Standard, Xamarin, and more. Features: rich built-in library of math functions, operators, constants. Flexible in user-defined arguments, functions. Expressions provided as plain text. Easy to use. Well documented.
OTHER License
Bot releases are visible (Hide)
Published by mariuszgromada 5 months ago
Published by mariuszgromada over 1 year ago
Published by mariuszgromada over 1 year ago
Published by mariuszgromada almost 2 years ago
Published by mariuszgromada about 2 years ago
Published by mariuszgromada over 2 years ago
Published by mariuszgromada over 2 years ago
Published by mariuszgromada over 2 years ago
Published by mariuszgromada over 2 years ago
Published by mariuszgromada over 2 years ago
#258
Published by mariuszgromada over 2 years ago
Published by mariuszgromada over 4 years ago
Published by mariuszgromada almost 5 years ago
ULP rounding is switched of as a default setting (can be enabled / disabled). As a default canonical rounding is switched on (can be disabled / enabled). New methods:
Example 1
Expression e = new Expression("0.1 + 0.1 + 0.1");
System.out.println("Pure Java : 0.1 + 0.1 + 0.1 = " + (0.1 + 0.1 + 0.1));
System.out.println("mXparser : 0.1 + 0.1 + 0.1 = " + e.calculate());
mXparser.disableCanonicalRounding();
System.out.println("mXparser canonical off: 0.1 + 0.1 + 0.1 = " + e.calculate());
===========
Pure Java : 0.1 + 0.1 + 0.1 = 0.30000000000000004
mXparser : 0.1 + 0.1 + 0.1 = 0.3
mXparser canonical off: 0.1 + 0.1 + 0.1 = 0.30000000000000004
Example 2
Expression e = new Expression("(-1/6.2)^(-3)");
System.out.println("Pure Java : (-1/6.2)^(-3) = " + Math.pow(-1/6.2, -3));
System.out.println("mXparser : (-1/6.2)^(-3) = " + e.calculate());
mXparser.disableCanonicalRounding();
System.out.println("mXparser canonical off: (-1/6.2)^(-3) = " + e.calculate());
===========
Pure Java : (-1/6.2)^(-3) = -238.32800000000003
mXparser : (-1/6.2)^(-3) = -238.328
mXparser canonical off: (-1/6.2)^(-3) = -238.32800000000003
Now you can define user arguments implementing your own algorithm in source code.
Example
class PiMultArgExt implements ArgumentExtension {
private int multiple = 0;
public double getArgumentValue() {
multiple++;
return MathConstants.PI * multiple;
}
public PiMultArgExt clone() {
return new PiMultArgExt();
}
}
Argument x = new Argument("x", new PiMultArgExt());
Expression e = new Expression("x/pi", x);
System.out.println("1st calc exec: " + e.calculate());
System.out.println("2nd calc exec: " + e.calculate());
System.out.println("3rd calc exec: " + e.calculate());
===========
1st calc exec: 1.0
2nd calc exec: 2.0
3rd calc exec: 3.0
Published by mariuszgromada over 5 years ago
Published by mariuszgromada almost 6 years ago
Published by mariuszgromada over 6 years ago
https://github.com/mariuszgromada/MathParser.org-mXparser/milestone/2
Published by mariuszgromada about 7 years ago
Published by mariuszgromada over 7 years ago
Published by mariuszgromada over 7 years ago
Published by mariuszgromada over 7 years ago
@~ - Bitwise unary complement
@& - Bitwise AND
@^ - Bitwise exclusive OR
@| - Bitwise inclusive OR
@<< - Signed left shift
@>> - Signed right shift
1.2e10
1.2e-10
1.2e+10
1.2E10
1.2E-10
1.2E+10
...
[%] - <Ratio, Fraction> Percentage = 0.01
[%%] - <Ratio, Fraction> Promil, Per mille = 0.001
[Y] - Septillion / Yotta = 10^24
[sept] - Septillion / Yotta = 10^24
[Z] - Sextillion / Zetta = 10^21
[sext] - Sextillion / Zetta = 10^21
[E] - Quintillion / Exa = 10^18
[quint] - Quintillion / Exa = 10^18
[P] - Quadrillion / Peta = 10^15
[quad] - Quadrillion / Peta = 10^15
[T] - Trillion / Tera = 10^12
[tril] - Trillion / Tera = 10^12
[G] - Billion / Giga = 10^9
[bil] - Billion / Giga = 10^9
[M] - Million / Mega = 10^6
[mil] - Million / Mega = 10^6
[k] - Thousand / Kilo = 10^3
[th] - Thousand / Kilo = 10^3
[hecto] - Hundred / Hecto = 10^2
[hund] - Hundred / Hecto = 10^2
[deca] - Ten / Deca = 10
[ten] - Ten / Deca = 10
[deci] - Tenth / Deci = 0.1
[centi] - Hundredth / Centi = 0.01
[milli] - Thousandth / Milli = 0.001
[mic] - Millionth / Micro = 10^-6
[n] - Billionth / Nano = 10^-9
[p] - Trillionth / Pico = 10^-12
[f] - Quadrillionth / Femto = 10^-15
[a] - Quintillionth / Atoo = 10^-18
[z] - Sextillionth / Zepto = 10^-21
[y] - Septillionth / Yocto = 10^-24
[m] - Metre / Meter (m=1)
[km] - Kilometre / Kilometer (m=1)
[cm] - Centimetre / Centimeter (m=1)
[mm] - Millimetre / Millimeter (m=1)
[inch] - Inch (m=1)
[yd] - Yard (m=1)
[ft] - Feet (m=1)
[mile] - Mile (m=1)
[nmi] - Nautical mile (m=1)
[m2] - Square metre / Square meter (m=
[cm2] - Square centimetre / Square cent
[mm2] - Square millimetre / Square mill
[are] - Are (m=1)
[ha] - Hectare (m=1)
[acre] - Acre (m=1)
[km2] - Square kilometre / Square kilom
[mm3] - Cubic millimetre / Cubic mill
[cm3] - Cubic centimetre / Cubic cent
[m3] - Cubic metre / Cubic meter (m=
[km3] - Cubic kilometre / Cubic kilom
[ml] - Millilitre / Milliliter (m=1)
[l] - Litre / Liter (m=1)
[gall] - Gallon (m=1)
[pint] - Pint (m=1)
[s] - Second (s=1)
[ms] - Millisecond (s=1)
[min] - Minute (s=1)
[h] - Hour (s=1)
[day] - Day (s=1)
[week] - Week (s=1)
[yearj] - Julian year = 365.25 days (s=1)
[kg] - Kilogram (kg=1)
[gr] - Gram (kg=1)
[mg] - Milligram (kg=1)
[dag] - Decagram (kg=1)
[t] - Tonne (kg=1)
[oz] - Ounce (kg=1)
[lb] - Pound (kg=1)
[b] - Bit (bit=1)
[kb] - Kilobit (bit=1)
[Mb] - Megabit (bit=1)
[Gb] - Gigabit (bit=1)
[Tb] - Terabit (bit=1)
[Pb] - Petabit (bit=1)
[Eb] - Exabit (bit=1)
[Zb] - Zettabit (bit=1)
[Yb] - Yottabit (bit=1)
[B] - Byte (bit=1)
[kB] - Kilobyte (bit=1)
[MB] - Megabyte (bit=1)
[GB] - Gigabyte (bit=1)
[TB] - Terabyte (bit=1)
[PB] - Petabyte (bit=1)
[EB] - Exabyte (bit=1)
[ZB] - Zettabyte (bit=1)
[YB] - Yottabyte (bit=1)
[J] - Joule (m=1, kg=1, s=1)
[eV] - Electronovolt (m=1, kg=1, s=1
[keV] - Kiloelectronovolt (m=1, kg=1,
[MeV] - Megaelectronovolt (m=1, kg=1,
[GeV] - Gigaelectronovolt (m=1, kg=1,
[TeV] - Teraelectronovolt (m=1, kg=1,
[m/s] - Metre / Meter per second (m=1,
[km/h] - Kilometre / Kilometer per hour
[mi/h] - Mile per hour (m=1, s=1)
[knot] - Knot (m=1, s=1)
[m/s2] - Metre / Meter per squar
[km/h2] - Kilometre / Kilometer p
[mi/h2] - Mile per square hour (m
[rad] - Radian (rad=1)
[deg] - Degree of arc (rad=1)
['] - Minute of arc (rad=1)
[''] - Second of arc (rad=1)
[c] - Light speed in vacuum [m/s] (m=1, s=1)
[G.] - Gravitational constant (m=1, kg=1, s=1)]
[g] - Gravitational acceleration on Earth [m/s^2] (m=1, s=1)
[hP] - Planck constant (m=1, kg=1, s=1)
[h-] - Reduced Planck constant / Dirac constant (m=1, kg=1, s=1)]
[lP] - Planck length [m] (m=1)
[mP] - Planck mass [kg] (kg=1)
[tP] - Planck time [s] (s=1)
[ly] - Light year [m] (m=1)
[au] - Astronomical unit [m] (m=1)
[pc] - Parsec [m] (m=1)
[kpc] - Kiloparsec [m] (m=1)
[Earth-R-eq - ]Earth equatorial radius [m] (m=1)
[Earth-R-po] - Earth polar radius [m] (m=1)
[Earth-R] - Earth mean radius (m=1)
[Earth-M] - Earth mass [kg] (kg=1)
[Earth-D] - Earth-Sun distance - semi major axis [m] (m=1)
[Moon-R] - Moon mean radius [m] (m=1)
[Moon-M] - Moon mass [kg] (kg=1)
[Moon-D] - Moon-Earth distance - semi major axis [m] (m=1)
[Solar-R] - Solar mean radius [m] (m=1)
[Solar-M] - Solar mass [kg] (kg=1)
[Mercury-R] - Mercury mean radius [m] (m=1)
[Mercury-M] - - Mercury mass [kg] (kg=1)
[Mercury-D]Mercury-Sun distance - semi major axis [m] (m=1)
[Venus-R] - Venus mean radius [m] (m=1)
[Venus-M] - Venus mass [kg] (kg=1)
[Venus-D] - Venus-Sun distance - semi major axis [m] (m=1)
[Mars-R] - Mars mean radius [m] (m=1)
[Mars-M] - Mars mass [kg] (kg=1)
[Mars-D] - Mars-Sun distance - semi major axis [m] (m=1)
[Jupiter-R] - Jupiter mean radius [m] (m=1)
[Jupiter-M] - Jupiter mass [kg] (kg=1)
[Jupiter-D] - Jupiter-Sun distance - semi major axis [m] (m=1)
[Saturn-R] - Saturn mean radius [m] (m=1)
[Saturn-M] - Saturn mass [kg] (kg=1)
[Saturn-D] - Saturn-Sun distance - semi major axis [m] (m=1)
[Uranus-R] - Uranus mean radius [m] (m=1)
[Uranus-M] - Uranus mass [kg] (kg=1)
[Uranus-D] - Uranus-Sun distance - semi major axis [m] (m=1)
[Neptune-R] - Neptune mean radius [m] (m=1)
[Neptune-M] - Neptune mass [kg] (kg=1)
[Neptune-D] - Neptune-Sun distance - semi major axis [m] (m=1)
solve( f(x), x, a, b ) - solving f(x) = 0
Better handling of invalid / not known tokens
Looks like functionality
FunctionExtension interface + new constructor in Function class
Exception thrown by getCopyOfInitialTokens() #21
System.format.exception - system.IO.EndOfStreamException #20
Expression relating factorial "!" cause the application to hang #17
Negative sign missing when is right of operators #16
Negative in if statement #12
Speed when debugging #11
User defined arguments ending in e #10
622 expression related tests
114 syntax related tests
30 api related tests
20 performance tests