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

QByteArray::toDouble() and qstrtod() function does not correctly parse the uppercase NaN

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.0
    • 5.12.0
    • None
    • Windows
    • 2ea3d2e924151843b8348871232eb88afb4cfe40 (qtbase/dev), a67e7e3bb (dev)

    Description

      All of these functions should return NaN, but QByteArray::toDouble() and qstrtod() returns 0.

      double dbl1 = QString::fromLatin1("NaN").toDouble(&ok);         // dbl1 = NaN, ok = true
      double dbl2 = QByteArray::fromRawData("NaN", 3).toDouble(&ok);  // dbl2 = 0, ok = false
      double dbl3 = qstrtod("NaN", nullptr, &ok);                     // dbl3 = 0, ok = false
      double dbl4 = strtod("NaN", nullptr);                           // dbl4 = NaN
      

      For lowercase "nan" all functions returns NaN, which is OK.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-74325
          # Subject Branch Project Status CR V

          Activity

            People

              thiago Thiago Macieira
              amiart Robert Szefner
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change