At 4/13/01 03:42 AM, Peter Holm wrote:
>mysql> select floor(23.49999999999999 + 0.5);
>+--------------------------------+
>| floor(23.49999999999999 + 0.5) |
>+--------------------------------+
>|                             23 |
>+--------------------------------+
>
>mysql> select floor(23.499999999999999 + 0.5);
>+---------------------------------+
>| floor(23.499999999999999 + 0.5) |
>+---------------------------------+
>|                              24 |
>+---------------------------------+
>
>Why are there different results?

Apparently the closest (most accurate) expression of the first constant 
(23.49999999999999) as a floating point number using binary arithmetic is 
less than 23.5 while the closest expression of the second constant 
(23.499999999999999) is 23.5 or greater. For some insight into why this 
happens, try to write 0.1 as the sum of reciprocal powers of 2 ( as in 1/16 
+ 1/32 + ... ).

--
Dennis Nichols
[EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to