Bug #2649 round(0.5) gives 0 (should be 1)

Submitted: 5 Feb 2004 3:08 Modified: 5 Feb 2004 6:09
Reporter: Serguei Sokol Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.15 OS:Linux (linux 2.4.22)
Assigned to: CPU Architecture:Any

[5 Feb 2004 3:08] Serguei Sokol
Description:
mysql> select round(0.5);
+------------+
| round(0.5) |
+------------+
|          0 |
+------------+
1 row in set (0.06 sec)

Obviously, the result should be 1.
It cannot be the problem of binary representation because
0.5 can be stored exactly in binary form (not something like 0.4999999)
The function round() of standard c math library do returns 1.

The same problem is observed with round(0.05,1) (gives 0.0 instead of 0.1)
and so on.

How to repeat:
select round(0.5);
[5 Feb 2004 6:09] Sergei Golubchik
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Additional info:

http://bugs.mysql.com/bug.php?id=2493

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.