Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3836

Investigate NODE-3835 - Incorrect Decimal128.fromString() for number with more than 34 significant digits

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed

      NODE-3835 Description

      What problem are you facing?

      Incorrect Decimal128.fromString() for number with more than 34 significant digits.

      What driver and relevant dependency versions are you using?

      node.js native mongodb driver 4.2.1 with bson 4.6.0

      Steps to reproduce?

      Decimal128.fromString('-46254.999999999999999132718749999999999998843625').toString()

      // got the wrong number -57365.00000000000000024382985000000

       

      Decimal128.fromString('-46254.99999999999999913271874999999').toString()

      // got the correct number -46254.9999999999999991327187499999

       

      Note that bson 1.x doesn't have this bug.

      // in bson 1.x

      Decimal128.fromString('-46254.999999999999999132718749999999999998843625').toString()

      // got the correct rounded number -46254.99999999999999913271875000000

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: