Bug #9060 Precision math: FORMAT returns incorrect result,
Submitted: 8 Mar 2005 22:47 Modified: 22 May 2005 23:55
Reporter: Petr Chloupek Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.23 OS:Linux (Debian)
Assigned to: Alexey Botchkov CPU Architecture:Any

[8 Mar 2005 22:47] Petr Chloupek
Description:
Precision math: FORMAT returns incorrect result, probably simillar to #8459

mysql> select format(4.55,1),format(4.551,1);
+----------------+-----------------+
| format(4.55,1) | format(4.551,1) |
+----------------+-----------------+
| 4.5            | 4.6             |
+----------------+-----------------+
1 row in set (0.00 sec)

At least very odd math, what is annoying when you are counting money. Maybe fixed somewhere in CVS, but I haven't found it in 4.0.24 change log.

How to repeat:
select format(4.55,1),format(4.551,1); in command line 'mysql' client.

Suggested fix:
fix rounding or explain in documentation if this is a feature. Just "rounding" is misleading.
[16 Mar 2005 8:01] Alexey Botchkov
First i should say that there's no Precision Math in 4.0 (neither in 4.1)
It only appeared in 5.0 version
[16 Mar 2005 19:40] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23106
[18 Mar 2005 8:23] Alexey Botchkov
bk commit - 4.0 tree (hf:1.2086) BUG#9060
[19 May 2005 12:49] Michael Widenius
This patch should only be pushed in 5.0 as 4.0 (and 4.1) doesn't have precision math and
4.55 is not an exact number and may thus be rounded either up or down.
[19 May 2005 20:13] Ramil Kalimullin
fixed in 5.0.6
[22 May 2005 23:55] Paul Dubois
Note in 5.0.6 changelog.