-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$round is rounding down to even numbers even when it's above the .5 threshold #347
Comments
Thanks for the report @praoshealth. Unfortunately, this is one of those problems that is hard to fix comprehensibly given how floating point arithmetic works in JS. See #305 and the question posed on the MongoDB forum. I think we can find an implementation that will be accurate for the given values, but I suspect there will still be a range of values that will round incorrectly with different decimal places. That said, I am happy to switch to an implementation which we think is better if the error rate is lowest for 4 or fewer decimal places which is reasonable in my view. The relevant code is here if you wanna take a stab at it. |
Thanks for the PR. Happy to merge it with some expanded test coverage. Please include your examples.
|
Resolved in 6.4.3. Thanks for the contribution. |
Actual Results
Expected Results
Also MongoDb seems to have an undocumented feature where if you pass in a numerical value instead of an array it defaults to a precision of 0
Actual Results
Expected Results
The text was updated successfully, but these errors were encountered: