Hi, I'm having some issues with BigDecimal. I wrote a custom document that accepts only numbers and some symbols as user input for a textfield. In this document I have a method that gets the input number as a BigDecimal (there are some other methods in the application that take BD as input).
In this method I get the text, use Number to format it, get the floatvalue and use it as the only argument in a contructor of a new BigDecimal. My problem only seems to occur when the float has a decimal value and its not .5. Ive checked the floatvalue and it seems to be ok there but if I print the BigDecimal value its off. See the following example:
1.00 float shows as 1.00 BigDecimal
1.10 shows as 1.10000002
1.20 shows as 1.20000005
1.30 shows as 1.29999998
1.40 shows as 1.39999998
1.50 shows as 1.5
Anyone know how I can avoid or get around this problem?
Kris McCuller
Programmer Portiva Corp.
kmcculler@portiva.com
In this method I get the text, use Number to format it, get the floatvalue and use it as the only argument in a contructor of a new BigDecimal. My problem only seems to occur when the float has a decimal value and its not .5. Ive checked the floatvalue and it seems to be ok there but if I print the BigDecimal value its off. See the following example:
1.00 float shows as 1.00 BigDecimal
1.10 shows as 1.10000002
1.20 shows as 1.20000005
1.30 shows as 1.29999998
1.40 shows as 1.39999998
1.50 shows as 1.5
Anyone know how I can avoid or get around this problem?
Kris McCuller
Programmer Portiva Corp.
kmcculler@portiva.com