[SERVER-75672] Classic engine incorrectly use 34 digits precision when converting from double to decimal Created: 04/Apr/23  Updated: 29/Oct/23  Resolved: 06/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Zixuan Zhuang Assignee: Davis Haupt (Inactive)
Resolution: Fixed Votes: 0
Labels: 7.1-Type-Precision-Fixes
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-68810 Complete TODO listed in SERVER-67282 Closed
Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0
Sprint: QI 2023-04-17
Participants:

 Description   

Classic engine use 34 digits precision when converting from double to decimal for left hand side of $add (double + decimal), while for other cases like right hand side of $add or $multiply 15 digits precision is used.

In SBE, 15 digits precision is used in all cases.

 

Per geert.bosch@mongodb.com, 15 digits precision is the correct one we should use

The conversion from double to Decimal uses 15 digits by default based on research done with product management, solution architects and customers. When users add 0.02 to a Decimal amount 0.98, they expect to get an exact 1.00, not some 0.999999999999... something, even if the update was specified using a double precision number, or the other way around. Fifteen decimal digits is the largest number that can round trip through double precision without loosing precision.



 Comments   
Comment by Githook User [ 05/Apr/23 ]

Author:

{'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}

Message: SERVER-75672 round to 15 digits when converting double to decimal for $add
Branch: master
https://github.com/mongodb/mongo/commit/4858d4fdec15b9856d2dc06141022bd4c846560b

Generated at Thu Feb 08 06:30:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.