Bug #9794 Rounding Error DECIMAL, FLOAT & DOUBLE
Submitted: 10 Apr 2005 18:10 Modified: 11 Apr 2005 5:58
Reporter: William Goudsbloem Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:4.0.20 OS:Linux (Linux Mandrake 10.1)
Assigned to: CPU Architecture:Any

[10 Apr 2005 18:10] William Goudsbloem
Description:
Column type = DECIMAL(10,2)

a insert off 44.955 will result in 44.95 instead of 44.96

How to repeat:
CREATE TABLE currency (
money DECIMAL(10,2)
);

INSERT INTO currency VALUES (44.955);

SELECT * FROM currency

+---------+
| money |
+---------+
| 44.95   |
+---------+
[11 Apr 2005 5:58] Hartmut Holzgraefe
Thank you for taking the time to report a problem.  Unfortunately
you are not using a current version of the product your reported a
problem with -- the problem might already be fixed. Please download
a new version from http://www.mysql.com/downloads/

If you are able to reproduce the bug with one of the latest versions,
please change the version on this bug report to the version you
tested and change the status back to "Open".  Again, thank you for
your continued support of MySQL.

Additional info:

Rounding behavior with DECIMAL is system dependant with MySQL 4.x
as float values and the systems lib round() function where used.

With MySQL 5.0 DECIMAL calculations are implemented as direct
operations that do not require conversion to float first so the usual
rounding problems with floats do not affect DECIMAL anymore