Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-71256

QLocale::toDouble return inf for incorrect input

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.12.1
    • 5.11.1
    • Core: Locales (i18n)
    • None
    • a9923674030980706940b3ee11145c38674bb35d (qt/qtbase/5.11)

       

      #include <QCoreApplication>
      #include <QLocale>
      #include <QString>
      #include <QDebug>
      int main(int argc, char *argv[])
      {
       QCoreApplication a(argc, argv);
      QLocale c(QLocale::C);
       bool ok;
       QString str = "1.7976931348623157e309";
       qDebug() << c.toDouble(str, &ok) << ok; // print "inf false"
      return a.exec();
      }
      

      From documentation: "Returns the double represented by the localized string s, or 0.0 if the conversion failed."

      In Qt4 the same code prints "0 false"
       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Eddy Edward Welbourne
            taurus Ivan Romanov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes