Subject Re: [firebird-support] Double precision field problem
Author Michael Weissenbacher
Hi,
>
> i am in trouble double precision field with subtract operation
> field1 is double precision
> field2 is double precision
> field1's value is 79.69
> field2's value is 78.12
> when i subtract field2 from field1 with this sql statement
> select field1 - field2 from table1
> the result is 1,56999999999999
> the result must be 1,57
No, it mustn't. Try the same with float/double in C, Java, Dephi or any
other language with float and I bet you'll get the same result. Floating
point numbers aren't exact decimal numbers, because they are stored as
binary fractions internally which can't always be mapped 1:1 to a
decimal. The number 0.1 (decimal) for example is the number
0.00011001100110011001100110011... (periorical) in binary and because of
that it can never really be stored in a float. As a "software and
database expert" you should know that :)

kind regards,
Michael