Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to write a decimals of the pression in QJson
Forum Updated to NodeBB v4.3 + New Features

How to write a decimals of the pression in QJson

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 909 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    suclida
    wrote on last edited by
    #1

    As we know, sometimes, a decimals in Dec couldn't transform to a bin, just like 0.1.
    It is different between string and decimal in Json format;
    so that a decimals in json may output like this: 0.9999999 or 0.100000001 .
    How can I write a decimals of the pression in QJson, just like 0.1 , 0.10 or 0.100? A string "0.1" or "0.10" isn't what I want.
    Thank you for your help!

    1 Reply Last reply
    0
    • Chris HennesC Offline
      Chris HennesC Offline
      Chris Hennes
      wrote on last edited by
      #2

      Are you trying to simply control the formatting of double output, or are you trying to get an exact representation of the number? Are you using JSON just internally, or does your app send data to others using these JSON files?

      Chris Hennes, Pioneer Library System

      S 1 Reply Last reply
      4
      • Chris HennesC Chris Hennes

        Are you trying to simply control the formatting of double output, or are you trying to get an exact representation of the number? Are you using JSON just internally, or does your app send data to others using these JSON files?

        S Offline
        S Offline
        suclida
        wrote on last edited by
        #3

        @Chris-Hennes said in How to write a decimals of the pression in QJson:

        Are you trying to simply control the formatting of double output, or are you trying to get an exact representation of the number? Are you using JSON just internally, or does your app send data to others using these JSON files?

        Thank you for your attention! Yes, I was trying to simply control the formatting of double output. My app send data to others using these JSON files(bytearray).

        1 Reply Last reply
        0
        • Chris HennesC Offline
          Chris HennesC Offline
          Chris Hennes
          wrote on last edited by
          #4

          Can I ask why you care? As you mention, the actual number being stored "under the hood" is not the rounded version. I know that JSON files are typically human-readable, but they are really designed for program-to-program communications.

          Chris Hennes, Pioneer Library System

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved