Uploaded image for project: 'MongoDB CLI Tools'
  1. MongoDB CLI Tools
  2. TOOLS-571

mongoimport should handle subnormal floating point numbers

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When handling a document containing a very small double, mongoimport fails to insert the document.

      For example, when trying to import the following document:

      { "val" : 6.916919041777452e-323 }

      mongoimport fails to insert the document and returns the following error:

      exception:BSON representation of supplied JSON is too large: code FailedToParse: FailedToParse: Value cannot fit in double: offset:7 of:{"val":6.916919041777452e-323}

      I would argue that, while not in contravention of RFC7159 (which leaves this as undefined behaviour), the fact that mongoimport chokes on e.g. 6.916919041777452e-323 is a bug, or at best inconsistent behaviour.

      For example, try passing the document {"val" : 3.141592653589793238462643383279} to mongoimport. It is successfully inserted, however when reading it back from the database we see {"val" : 3.141592653589793}, which is the closest representation as a IEEE 754 binary64. To me, it doesn't make sense that we exhibit this "store as nearest possible BSON representation" behaviour for some inputs but not for others. It would be better if we were consistently lenient, since we certainly don't guarantee to preserve numerical accuracy as we can see from the above example.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jon.rangel Jon Rangel
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: