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

QLocale::toDouble return inf for incorrect input

    XMLWordPrintable

Details

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

    Description

       

      #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"
       

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes