Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1516
Closed
Open
Issue created Mar 03, 2021 by Benoît Blanchon@bblanchonOwner

1.7976931348623147e308 is serialized to 1.797693135e308, which is out of double's range

StaticJsonDocument<300> doc;
doc.set(1.7976931348623147e+308);
serializeJson(doc, std::cout); // 1.797693135e308

Online demo: https://wandbox.org/permlink/sJfBXevl6vd3KDL5

The rounding is correct, but the value is out of double's range. This can be an issue because when we deserialize the document, we get inf.

One way to mitigate this issue would be to reduce the value before stringification, like so:

// prevent rounding out of double's range
if (value > 1.797693134e308) 
  value = 1.797693134e308

Another option would be to add some slack in the deserialization code so that it returns 1.7976931348623147e+308 instead of inf.

I'm not sure if this issue classifies itself as a bug since the workaround can be considered a bug as well.

Assignee
Assign to
Time tracking