db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Lichtman <swa...@rcn.com>
Subject Re: Problem with decimal precision
Date Wed, 02 Mar 2005 19:56:12 GMT

>   I have a field decimal(10,2) where I insert "32,78", but when I go
>to look at in the table the inserted value was "32,77", alguem which
>the problem?

This is probably caused by the fact that you are inserting the value as a 
double. Doubles are not exact values - my guess is that 32.78 is being 
converted to 32.779999... (or something like that) and then being truncated 
to 32.77.

To insert into a decimal column, it's better to use the method 
setBigDecimal() with the class java.math.BigDecimal.


                        -        Jeff Lichtman
                                 swazoo@rcn.com
                                 Check out Swazoo Koolak's Web Jukebox at
                                 http://swazoo.com/ 


Mime
View raw message