Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    3
    3918
    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.
    • kybernetes
      kybernetes last edited by kybernetes

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • kybernetes
          kybernetes last edited by

          Thank you.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post