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

Round Decimal128::to{Int,Long,IntExact,LongExact,ULongExact} toward zero

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Storage
    • Labels:
    • Storage Execution
    • Execution Team 2020-09-21, Execution Team 2020-10-05, Execution Team 2020-10-19

      BSONElement::numberInt truncates fractional part of double using C-style cast.
      For Decimal values this methods uses Decimal128::toInt without any arguments.
      This makes Decimal128::toInt to use kRoundTiesToEven rounding strategy (round to nearest integer).
      As a result BSONElement::numberInt has different truncation/rounding rules for double and Decimal128 which can be misleading (see SERVER-32960).

      Same is valid for BSONElement::numberLong

      The best fix is to default these methods to rounding toward zero. Examination of the call sites revealed a similar issue with document value.

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            nikita.lapkov@mongodb.com Nikita Lapkov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: