[MDEV-6851] Decimal multiplication loses precision for no good reason Created: 2014-10-08  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 5.1.67, 5.2.14, 5.3.12, 5.5, 10.0, 10.1
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: upstream, verified

Issue Links:
Relates
relates to MDEV-6841 test decimal math Open

 Description   

MariaDB [test]> select 0.00000000000000000000000001035 * 100000000000000000000000000000000000000000000;
+---------------------------------------------------------------------------------+
| 0.00000000000000000000000001035 * 100000000000000000000000000000000000000000000 |
+---------------------------------------------------------------------------------+
|                               1000000000000000000.00000000000000000000000000000 |
+---------------------------------------------------------------------------------+

Same result on MySQL.
Both values are within DECIMAL range, so there should be no loss.

PostgeSQL returns the precise result:

postgres=# select 0.000000000000000000000000001035 * 100000000000000000000000000000000000000000000000000;
                        ?column?                         
---------------------------------------------------------
 103500000000000000000000.000000000000000000000000000000
(1 row)


Generated at Thu Feb 08 07:15:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.