Hi,
 
Is this a problem with all database systems or is it only unique to SQLite?
 
__
Raymond Irving

"D. Richard Hipp" <[EMAIL PROTECTED]> wrote:
The value 1.2 cannot be represented exactly in a (finite-length)
binary number. On my machine, 1.2 gets stored as

1.1999999999999999555910790149937383830547332763671875

Whenever you print this out to a reasonable number of digits,
it gets rounded to 1.2. But internally, the value is never 1.2.
The value 1.2 simply cannot be stored in an 8-byte IEEE floating
point number.

If you are storing dollars and cents, only 4 cents values out of
100 can be represented exactly in binary: 0.00, 0.25, 0.50, and
0.75. Any other cents value will be approximated. When you add
up a large number of dollars+cents values, the approximation errors
will hopefully cancel each other out and you will get a result that
is a good approximation. But there are no guarantees. The errors
might accumulate so that your answer is a penny or two different
from what you accountant thinks it ought to be. If you need to
be 100% dead-on accurate to the penny, you should store your
dollars+cents values as an integer number of cents.
-- 
D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to