Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2341

Approximative encoding of floats in canonical extended JSON

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Float are encoded as BSON "$numberDouble" with an incorrect value.

      echo MongoDB\BSON\Document::fromPHP(['x' => 1.99])->toCanonicalExtendedJSON();
      
      // Actual
      // { "x" : { "$numberDouble" : "1.9899999999999999911" } }
      
      // Expected
      // { "x" : { "$numberDouble" : "1.99" } }
      

            Assignee:
            andreas.braun@mongodb.com Andreas Braun
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: