Bug #15254 4.0.26 bug Report: ROUND()
Submitted: 26 Nov 2005 1:39 Modified: 26 Nov 2005 2:33
Reporter: Sheng Wen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0 OS:Windows (Windows 2000 Server)
Assigned to: CPU Architecture:Any

[26 Nov 2005 1:39] Sheng Wen
Description:
mySQL 4.0.26:
SELECT ROUND(297.49,0);   -> 297
SELECT ROUND(297.50,0);   -> 297  (error, correct values is 298)
SELECT ROUND(297.51,0);   -> 298
SELECT ROUND(297.52,0);   -> 298

mySQL 5.0.16:
SELECT ROUND(297.49,0);   -> 297
SELECT ROUND(297.50,0);   -> 298
SELECT ROUND(297.51,0);   -> 298
SELECT ROUND(297.52,0);   -> 298

How to repeat:
SELECT ROUND(297.50,0);   -> correct values is 298
[26 Nov 2005 2:33] Jim Winstead
From the manual (http://dev.mysql.com/doc/refman/4.1/en/mathematical-functions.html):

  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.