[SERVER-29679] $inc generating some wrong value when incremented with negative decimal value Created: 16/Jun/17 Updated: 27/Oct/23 Resolved: 16/Jun/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 3.4.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Suraj Sawant | Assignee: | Mark Agarunov |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Operating System: | ALL | ||||
| Steps To Reproduce: | 1.Insert
2.check results
3.increment the value with negative fractional value
4.check the output
Actual Output: "qty" : 3.8560000000000003 |
||||
| Participants: | |||||
| Description |
|
While using $inc to decrement a value by some fractional value,ganerated output differs with expected output. |
| Comments |
| Comment by Mark Agarunov [ 16/Jun/17 ] |
|
Hello sawantsuraj91@gmail.com, Thank you for the report. What you are seeing appears to relative error be due to IEEE-754 Floating point math. Due to the way floating point numbers are represented, the actual values being added are binary approximations of the numbers inserted, which is why the output is not the exact expected value. Unfortunately this is an unavoidable property of floating point arithmetic. Thanks, |