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
  • #67
Closed
Open
Issue created Apr 21, 2015 by Administrator@rootContributor

Stack overflow when printing double

Created by: miloyip

When printing large/small doubles, using %f will generate very long output and generate stack overflow, as shown in the following debug section:

frame #4: 0x0000000100006361 nativejson_debug_x64_gmake`Print::print(this=0x00007fff5fbfe5c0, value=1.7976931348623157E+308, digits=20) + 129 at Print.cpp:24
   21   size_t Print::print(double value, int digits) {
   22     char tmp[32];
   23     sprintf(tmp, "%.*f", digits, value);
-> 24     return print(tmp);
   25   }
   26   
   27   size_t Print::print(long value) {

(lldb) p tmp
(char [32]) $0 = "179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000000000000000

I think a suitable format should be %.*g, though the meaning of digits are not the same.

Assignee
Assign to
Time tracking