Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-80021

Make $convert round-trip correctly between double and string

    • Query Execution
    • Fully Compatible
    • ALL
    • v7.1, v7.0, v6.0, v5.0, v4.4
    • Hide

      db.c.aggregate([\{$project: {converted: {$convert: {input: 5909.123456, to: "string"}}}}]) gives 5909.12 .

      Show
      db.c.aggregate( [\{$project: {converted: {$convert: {input: 5909.123456, to: "string"}}}}] )  gives  5909.12  .
    • QE 2023-09-18
    • 138

      We lose precision when we perform the conversion from double to string. Link to code. The default precision for a double in str::stream is set to 6 digits, which causes the loss of precision.

      This problem was identified in HELP-48955.

      We should change it so that we get a string representing the exact same doubleValue and can roundtrip and retrieve the same value back.

      We also want comprehensive and randomized tests to verify this behavior. 

            Assignee:
            adi.agrawal@mongodb.com Adi Agrawal
            Reporter:
            adi.agrawal@mongodb.com Adi Agrawal
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: