[SERVER-40055] Bug in round for doubles with no second argument Created: 08/Mar/19  Updated: 29/Oct/23  Resolved: 07/May/19

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.1.11

Type: Bug Priority: Major - P3
Reporter: Patrick Meredith Assignee: Charlie Swanson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2019-04-22, Query 2019-05-06, Query 2019-05-20
Participants:

 Description   

Ties round up when they should round to even, when no second argument to round is supplied.

in pseudo code:

round(NumberDecimal("1234.5", 0) = NumberDecimal("1234") //good
round(NumberDecimal("1234.5") = NumberDecimal("1234") //good
round(1234.5, 0) = 1234 //good
round(1234.5) = 1235 // bad

The problem here is that we are using `std::round` for doubles when no second argument is passed, otherwise we use `Decimal128::quantize`, with round ties to even.



 Comments   
Comment by Githook User [ 07/May/19 ]

Author:

{'name': 'Charlie Swanson', 'username': 'cswanson310', 'email': 'charlie.swanson@mongodb.com'}

Message: SERVER-40055 Consolidate $round behavior with and without a default
Branch: master
https://github.com/mongodb/mongo/commit/96e96c3af633f856dc0bb695c3fe0691a16459e0

Comment by Patrick Meredith [ 08/Mar/19 ]

Feel free to assign to me, since the bug is mine

Generated at Thu Feb 08 04:53:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.