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
  • #588
Closed
Open
Issue created Oct 14, 2017 by Administrator@rootContributor

float serialization

Created by: alex9x

Hi! Please, help with float serialization.

Function to cut one decimal and part of code: ` float Round1(float tmp) { return ((int)(tmp * 10)) / 10.0; }

DynamicJsonBuffer jsonBuffer(200); JsonObject& log = jsonBuffer.createObject(); tmp_t=24.35141; // float value from sensor log["dht_t"] = Round1(tmp_t); // cut to one decimal ` got results in log file:

{"dht_t":24} {"dht_t":24.1} {"dht_t":24.2} {"dht_t":24.29999} - for 24.3 {"dht_t":24.4} {"dht_t":24.5} {"dht_t":24.6} {"dht_t":24.7} {"dht_t":24.79999} - for 24.8 {"dht_t":24.9}

problem with x.3 and x.8

Any help are welcome!

Assignee
Assign to
Time tracking