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

QString::toDouble() doesn't parse -/+Infinity

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.10.0, 5.9.4
    • None
    • Windows 10 x64, MSVC2015 x32

      The standard C++11 function std::stod and atof() can parse -/+Infinity constant,
      but QString::toDouble() not:

      bool ok;
      double v1 = QString("Infinity").toDouble(&ok);   // v1=0, ok=false
      double v2 = QString("+Infinity").toDouble(&ok);  // v2=0, ok=false
      double v3 = QString("-Infinity").toDouble(&ok);  // v3=0, ok=false
      
      double v4 = atof("Infinity");   // v4=inf
      double v5 = atof("+Infinity");  // v5=inf
      double v6 = atof("-Infinity");  // v6=-inf
      

      http://en.cppreference.com/w/cpp/string/basic_string/stof
      http://www.cplusplus.com/reference/cstdlib/atof/?kw=atof

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes