Bug #36318 precision lost
Submitted: 24 Apr 2008 14:19 Modified: 24 Apr 2008 16:06
Reporter: Matthew Montgomery Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Parser Severity:S2 (Serious)
Version:5.0.45, 5.1.24 OS:Linux (2.6.22-14-generic i686)
Assigned to: CPU Architecture:Any

[24 Apr 2008 14:19] Matthew Montgomery
Description:
Precision is lost from multipliers resulting in a (X * 0) product.  By modifying the precision of the input values slightly (but not the value themselves), or by grouping them we can cause mysqld to handle this properly.

How to repeat:
In 5.0, 5.1

mysql> select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * 0.99500000);
+---------------------------------------------------------------------------------------------------------+
| (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * 0.99500000) |
+---------------------------------------------------------------------------------------------------------+
|                                                                        0.000000000000000000000000000000 | 
+---------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * .99500000);
+--------------------------------------------------------------------------------------------------------+
| (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * .99500000) |
+--------------------------------------------------------------------------------------------------------+
|                                                                       0.812988073953673124592306939480 | 
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.015 * 0.995);
+-----------------------------------------------------------------------------------------------+
| (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.015 * 0.995) |
+-----------------------------------------------------------------------------------------------+
|                                                              0.812988073953673124592306939480 | 
+-----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select (1.20396873 * 0.89550000 ) * ( 0.68000000 * 1.08721696 ) * ( 0.99500000 * 1.01500000 ) * ( 1.01500000 * 0.99500000 );
+----------------------------------------------------------------------------------------------------------------------+
| (1.20396873 * 0.89550000 ) * ( 0.68000000 * 1.08721696 ) * ( 0.99500000 * 1.01500000 ) * ( 1.01500000 * 0.99500000 ) |
+----------------------------------------------------------------------------------------------------------------------+
|                                                                                     0.812988073953673124592306939480 | 
+----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Suggested fix:
.
[24 Apr 2008 16:06] Valeriy Kravchuk
This is a duplicate of bug #36270.