[SERVER-20975] Aggregation $sum has some odd rounding erorrs. Created: 16/Oct/15 Updated: 17/Oct/15 Resolved: 16/Oct/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 2.6.10, 3.2.0-rc0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | John Page | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible | |||
| Operating System: | ALL | |||
| Steps To Reproduce: |
|
|||
| Participants: |
| Description |
|
If I use $sum to add some simple floating point numbers together in MongoDB 2.6 or 3.2 I see really odd rounding.
Same applies to 3.3 + 3.9 = 7.199999999999999 |
| Comments |
| Comment by Charlie Swanson [ 16/Oct/15 ] |
|
I don't think there's anything reasonable we can do about this. In the future, the new Decimal data type could be used if you wanted to represent decimals precisely. |
| Comment by Adam Midvidy [ 16/Oct/15 ] |
|
This seems like expected IEEE-754 behavior: e.g. 3.3 + 3.9 will give you 7.19999999999 ... in Python or any other environment that uses binary floats. |