Bug #5059 float multiplication

Submitted: 15 Aug 2004 12:27 Modified: 16 Aug 2004 19:44
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.0.16 and 4.0.20a-nt OS:both fbsd and winxp
Assigned to: Dean Ellis CPU Architecture:Any

[15 Aug 2004 12:27] [ name withheld ]
Description:
mysql> select a,b,a*b from tmp;
+-------+-------+-----------------+
| a     | b     | a*b             |
+-------+-------+-----------------+
| 26.82 | 746.9 | 20031.858426849 |
+-------+-------+-----------------+

congratulations.

How to repeat:
just create a table with two float fields, insert those values and type that select.

Suggested fix:
rewrite the whole code.
[16 Aug 2004 19:44] Dean Ellis
This is a simple precision error, which is common when dealing with floating point numbers.  You could use DOUBLE/DECIMAL/NUMERIC or restrict the apparent final precision with ROUND().  Also, see: http://dev.mysql.com/doc/mysql/en/Problems_with_float.html

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

Page generated in 0.048 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.