Bug #2493 Round function doesn't work correctly
Submitted: 23 Jan 2004 11:22 Modified: 2 Feb 2004 14:22
Reporter: Paco O. Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:4.0.16 OS:Microsoft Windows (Windows)
Assigned to: Sergei Golubchik CPU Architecture:Any

[23 Jan 2004 11:22] Paco O.
Description:
If round function is called, for example: round(9.5) it returns 9 but it must returns 10. Other example: round(10.005,2) returns 10.01, that is correct, but round(10.015,2) returns 10.01 but it must be 10.02

How to repeat:
select round(9.5)
select round(10.005,2)
select round(10.015,2)

Suggested fix:
If the next decimal digit to the number of decimals indicated is 5 or greater it must be rounded up, in other way it mus be rounded down.
[23 Jan 2004 20:03] Miguel Solorzano
Serg I am assign you because I guess you already discussed this
issue.
[2 Feb 2004 14:22] Sergei Golubchik
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

There are different ways to round. MySQL simply calls libc round(). So the behaviour is defined by the underlying OS. In some implementations int+0.5 is rounder up, is others it is rounder to the closest even integer.

SQL:2003 standard itself does not contain any ROUND() function.