Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40055

Bug in round for doubles with no second argument

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.11
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Query 2019-04-22, Query 2019-05-06, Query 2019-05-20

      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.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            patrick.meredith@mongodb.com Patrick Meredith
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: