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. QVariant::toString - default precision setting changed?
QtWS25 Last Chance

QVariant::toString - default precision setting changed?

Scheduled Pinned Locked Moved Solved General and Desktop
qvarianttostringprecision
4 Posts 2 Posters 2.4k 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.
  • S Offline
    S Offline
    stryga42
    wrote on 13 May 2016, 12:57 last edited by
    #1

    Hello!
    I recompiled my application using Qt5.6 and VS2015 (win32) and noticed that QVariant::toString nowadays converts with "full precission", thereby showing the non-perfect representation of many decimal values. Although not wrong by itself it is very confusing for the user. E.g. 59.600000000000001 where the user would expect 59.6. The same source, compiled with VS2008 and Qt5.4 displays the rounded values.
    Of course I can work around that by QString::number(QVariant::toDouble()) but I am slightly troubled aboubt this silent change in behaviour and I wonder if it is due to Qt5.4 -> Qt5.6 or VS2008 -> VS2015 (which I can't test, because i have no VS2008 at hand any more):
    Did anyone else observe similar changes and what do you think about it? Does it qualify as a bug?
    stryga42

    ? 1 Reply Last reply 13 May 2016, 13:18
    0
    • S stryga42
      13 May 2016, 12:57

      Hello!
      I recompiled my application using Qt5.6 and VS2015 (win32) and noticed that QVariant::toString nowadays converts with "full precission", thereby showing the non-perfect representation of many decimal values. Although not wrong by itself it is very confusing for the user. E.g. 59.600000000000001 where the user would expect 59.6. The same source, compiled with VS2008 and Qt5.4 displays the rounded values.
      Of course I can work around that by QString::number(QVariant::toDouble()) but I am slightly troubled aboubt this silent change in behaviour and I wonder if it is due to Qt5.4 -> Qt5.6 or VS2008 -> VS2015 (which I can't test, because i have no VS2008 at hand any more):
      Did anyone else observe similar changes and what do you think about it? Does it qualify as a bug?
      stryga42

      ? Offline
      ? Offline
      A Former User
      wrote on 13 May 2016, 13:18 last edited by
      #2

      @stryga42 Hi, and welcome to the Qt forum! The dev who introduced the change in behaviour says that it's not a bug but a feature, see QTBUG-47192.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        stryga42
        wrote on 13 May 2016, 14:42 last edited by
        #3

        Well, got it, thanks for pointing to the bug report. Would be great if the doc for QVariant::toString could elaborate more about how string conversion is done for non-string types of QVariant. Would save some debugging :-)
        Is there a bug-tracker for the documentation where I coulld add my request?
        Thanks, stryga42

        ? 1 Reply Last reply 13 May 2016, 14:43
        0
        • S stryga42
          13 May 2016, 14:42

          Well, got it, thanks for pointing to the bug report. Would be great if the doc for QVariant::toString could elaborate more about how string conversion is done for non-string types of QVariant. Would save some debugging :-)
          Is there a bug-tracker for the documentation where I coulld add my request?
          Thanks, stryga42

          ? Offline
          ? Offline
          A Former User
          wrote on 13 May 2016, 14:43 last edited by
          #4

          @stryga42 You can use the bug tracker for documentation bugs / requests, too: https://bugreports.qt.io.

          1 Reply Last reply
          0

          4/4

          13 May 2016, 14:43

          • Login

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