Hello Carl
Your problem is that you are passing a float variable to the BigDecimal
constructor, where the float variable cannot accurately represent the
number you are trying to use. If you use the string constructor, then
your code will work as expected:
BigDeicmal db = new BigDecimal("10099999.0499");
Floats or doubles cannot accurately represent all real numbers. So, the
actual value of the float variable in memory is 10099999, not the
literal value 10099999.0499 in your code. Passing this to the
constructor of BigDecimal does not help, as BigDecimal cannot know that
you intended to use the number 10099999.0499, it can only know this if
you use the String constructor.
Also, Float.MAX_VALUE only tells you the maximum value for a float, it
does not tell you whether a number can be accurately represented as
float or not.
Here are some hopefully helpfull links:
http://www.softwaresummit.com/2004/speakers/CowlishawBigDecimal.pdf
http://www.ddj.com/184405721?pgno=1
James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---