Serena Lien wrote:
I have read some of the postings/faq about the difficulties with the round
function, when certain numbers do not have a finite representation in
binary, which SQLite uses. eg 9.95 is actually 9.9499...etc so that round(
9.95, 1) rounds down.
But, I have found several numbers which don't get rounded at all, and in
fact return more decimal places!
round(98926650.5, 1) -> 98926650.5000001
round(85227887.01, 1) -> 85227887.0000001
Even if these numbers cannot be represented properly in binary, why is it
they aren't rounded?
thanks for any assistance,
Serena
They are in fact rounded, but the internal binary representation can not
be turned
into the appropriate decimal (and human readable) representation due to the
finite precision.
A number like 1.511 can be rounded to 1.5 and that is _exactly_
representable
as binary number. But if, as in your examples, the number requires more
precision
than is available (remember: only a finite number of digits/bits in
total, no matter
what the position of the decimal point/comma), the old problem of binary-to-
decimal conversion kicks in again.
Regards,
Arjen
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------