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:
.