I think the point of the JavaDoc write up is that:
new BigDecimal(((Double) value).doubleValue()) != new BigDecimal(((Double)
value).toString())
BUT
BigDecimal.valueOf(((Double) value).doubleValue()) == new BigDecimal(((Double)
value).toString())
In other words, instead of using the BigDecimal double constructor, we should
be using the BigDecimal.valueOf(double) method.
Whatever the case relying on this value without rounding can be dangerous...
This may help a lot for most circumstances though, so I'll go ahead and throw
it in (the valueOf variation to avoid the overhead of creating a String to
throw away).
That is in SVN rev 576660.
-David
Jacopo Cappellato wrote:
What do you think about the attached patch?
I really think it should be committed to the trunk, especially after
reading the following notes:
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(double)
However, I'd like to get feedback from you before committing it since it
is a low level change.
Jacopo
PS: thanks to Martin Anderson from the patch and research around it.