fasseg / exp4j

A tiny math expression evaluator for the Java programming language
http://www.objecthunter.net/exp4j/
Apache License 2.0
489 stars 163 forks source link

Precision deficiency #123

Open oneMord opened 1 day ago

oneMord commented 1 day ago

0.48 2.38 / 5 10 = 1.95159999999

The correct answer should be 1.9516

RobertZenz commented 1 day ago

exp4j uses doubles, which are floating-point numbers which are by definition inaccurate.

If you need arbitrary precision you need to use something like EvalEx which uses BigDecimal.