Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.7, 1.6-beta-2
-
None
-
None
Description
The current implementation of DGM.toBigDecimal uses a new BigDecimal(Number.doubleValue()) to do the conversion. As the docs on BigDecimal(double) explain, that may result in a bunch of insignificant digits yielding a decimal number that is not what the user expects (or wants).
http://java.sun.com/javase/6/docs/api/java/lang/Double.html#toString(double)
That means we get this:
println (0.1f as BigDecimal)
==>
0.100000001490116119384765625
So the preferred method is to use new BigDecimal(Double.toString()) which will round off insignificant digits.
So that now we get this:
println (0.1f as BigDecimal)
==>
0.1
and most reassuringly this is now true (which fails in 1.5.x):
assert (0.1 == (0.1f as BigDecimal))