Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4335 negative 0 should serialize to Double
  3. NODE-4464

Negative zero not handled properly in extended JSON

    • Type: Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • bson-5.0.0
    • Affects Version/s: bson-4.6.5
    • Component/s: EJSON
    • 3
    • Not Needed
    • Not Needed

      What problem are you facing?

      Spec tests say -0 should be serialized to EJSON differently from +0:

      https://github.com/mongodb/specifications/blob/bafb024be8202b1676a3c6632e8a3eb9cf36209b/source/bson-corpus/tests/double.json#L42-L53

      This isn’t something that’s easily fixable for the relaxed EJSON, since JSON.stringify(-0) === '0', but should be fixable for canonical EJSON.

      (This only occurs with -0 JS numbers, not Double(-0) bson objects.)

      What driver and relevant dependency versions are you using?

      Latest js-bson (4.6.5).

      Steps to reproduce?

      > EJSON.stringify({ neg: -0, pos: 0 }, { relaxed: false })
      '{"neg":{"$numberInt":"0"},"pos":{"$numberInt":"0"}}'
      

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: