Double value retrieved from bson is different than expected

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.13.0
    • Component/s: libbson
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Example code:

      #include <bson.h>
      #include <stdio.h>
       
      int main() {
       bson_t b = BSON_INITIALIZER;
       BSON_APPEND_DOUBLE (&b, "a", 3399.99);
       
       size_t len;
       char *str;
       str = bson_as_json (&b, &len);
       printf ("%s\n", str);
       
       bson_free (str);
       return 0;
      }

      Actual output:

      { "a" : 3399.9899999999997817}

      Expected output:

      { "a" : 3399.99}

       

       

            Assignee:
            Jeremy Mikola
            Reporter:
            Aziz Zitouni
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: