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 convert Qstring to floating point which has more than 6 digits after comma

How to convert Qstring to floating point which has more than 6 digits after comma

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 4.3k Views
  • 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.
  • kybernetesK Offline
    kybernetesK Offline
    kybernetes
    wrote on last edited by kybernetes
    #1

    hello,

    I am tring to convert a string to float but i loose digits after comma

    For example

    string = "0,123456789"

    when i use

    qDebug() << string.tofloat()

    İt is written like this (it rounds after 6th digit)

    0,123457

    How can i solve it i want to use all the 9 digits after comma

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can change the precision of qDebug using qSetRealNumberPrecision. The default is six hence your result but your float value should be fine to use.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • kybernetesK Offline
        kybernetesK Offline
        kybernetes
        wrote on last edited by
        #3

        Thank you.

        1 Reply Last reply
        0

        • Login

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