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

XMLWordPrintableJSON

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

      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:
              [DO NOT USE] Backlog - Storage Execution Team
              Reporter:
              Nikita Lapkov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated: