Incorrect binary data Decimal128.fromString (bson-ext)

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: bson-ext-4.0.0
    • Component/s: EJSON
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      This issue was originally reported for js-bson but is also present for bson-ext. The js-bson fix should apply to bson-ext, but we should double check and add the appropriate tests.
      ---------
      https://github.com/mongodb/js-bson/issues/334

      Hello. Decimal128.fromString is working incorrect, you can reproduce bug using negative numbers of pattern 0.00XX :

      bson.Decimal128.fromString('-0.0097').toString() // -0.0000
      bson.Decimal128.fromString('-0.0011').toString() // -0.0000
      

      Same numbers, but with different zero count will work:

      bson.Decimal128.fromString('-0.00970').toString() // -0.00970
      bson.Decimal128.fromString('-0.00110').toString() // -0.00110
      bson.Decimal128.fromString('-0.00010').toString() // -0.00110
      

      bson package version is 4.0.2

              Assignee:
              Daria Pardue
              Reporter:
              Daria Pardue
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: