Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved How to write a decimals of the pression in QJson

    General and Desktop
    2
    4
    657
    Loading More Posts
    • 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
      suclida last edited by

      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 Reply Quote 0
      • Chris Hennes
        Chris Hennes last edited by

        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 Reply Quote 4
        • S
          suclida @Chris Hennes last edited by

          @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 Reply Quote 0
          • Chris Hennes
            Chris Hennes last edited by

            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 Reply Quote 2
            • First post
              Last post