Bug #9732 Precision math: Error when multiplying large numbers
Submitted: 7 Apr 2005 21:18 Modified: 15 Jun 2005 8:47
Reporter: Trudy Pelzer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.4-alpha-debug OS:Linux (SuSE 9.1)
Assigned to: Alexey Botchkov CPU Architecture:Any

[7 Apr 2005 21:18] Trudy Pelzer
Description:
When I multiply large decimal values, I eventually
get an incorrect result. It may be that I have hit
the maximum possible size of an operation; if
that is the case, MySQL should return an error
rather than an incorrect result.

How to repeat:
mysql> select 5000000000000000000000000000000000000 * -50000000000000000000000000.5;
+-----------------------------------------------------------------------+
| 5000000000000000000000000000000000000 * -50000000000000000000000000.5 |
+-----------------------------------------------------------------------+
| -250000000000000000000000002500000000000000000000000000000000000.0    |
+-----------------------------------------------------------------------+
1 row in set (0.00 sec)
-- This is the correct result.

mysql> select 5000000000000000000000000000000000000 * -500000000000000000000000000.5;
+------------------------------------------------------------------------+
| 5000000000000000000000000000000000000 * -500000000000000000000000000.5 |
+------------------------------------------------------------------------+
| -2500000000000000000000000000000000000000000000000000000000000000      |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)
-- I add one more zero to the second operand and get the wrong
answer. MySQL should either return the correct answer or (if the
operation is too large) an error message saying that the requested
calculation cannot be performed.