Bug #9957 select round(87.875,2); wrong result on WinXp and MySQL 4.1.11
Submitted: 17 Apr 2005 9:57 Modified: 18 Apr 2005 17:04
Reporter: a a Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S1 (Critical)
Version:4.1.11 OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[17 Apr 2005 9:57] a a
Description:
> select  round(87.875,2);
+------------+
| round(87.875,2)|
+------------+
| 87.87          |
+------------+

but correct result 87.88

How to repeat:
> select  round(87.875,2);
+------------+
| round(87.875,2)|
+------------+
| 87.87          |
+------------+

but correct result 87.88
[17 Apr 2005 18:08] Jorge del Conde
Hi!

I was unable to reproduce this bug using 4.1.11 from bk:

mysql> select  round(87.875,2);
+-----------------+
| round(87.875,2) |
+-----------------+
|           87.88 |
+-----------------+
1 row in set (0.00 sec)
[18 Apr 2005 12:10] a a
i am using WinXP an MySQL 4.1.11

my result : 87.77
[18 Apr 2005 14:07] a a
sorry for last comment.

my result : 87.87
[18 Apr 2005 17:01] Jorge del Conde
Hi!

These results are because different C libs follow different rounding rules on round().  While this problem won't be fixed in MySQL < 5.0, it's already fixed in 5.0.3.
[18 Apr 2005 17:04] Jorge del Conde
This is from our manual: Note that the behavior of ROUND() when the argument is halfway between two integers depends on the C library implementation. Different implementations round to the nearest even number, always up, always down, or always toward zero. If you need one kind of rounding, you should use a well-defined function such as TRUNCATE() or FLOOR() instead.