#endif
#include <private/qutfcodec_p.h>
#include "qsimd_p.h"
+#include <qnumeric.h>
#include <qdatastream.h>
#include <qlist.h>
#include "qlocale.h"
{
bool myOk;
double d = toDouble(&myOk);
- if (!myOk || d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) {
+ if (!myOk) {
+ if (ok != 0)
+ *ok = false;
+ return 0.0;
+ }
+ if (qIsInf(d))
+ return float(d);
+ if (d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) {
if (ok != 0)
*ok = false;
return 0.0;
}
if (ok != 0)
*ok = true;
- return (float) d;
+ return float(d);
}
/*! \fn QString &QString::setNum(int n, int base)
QString("0INF0").toLong(&ok, 36);
QVERIFY(ok);
+
+ // Check that inf (float) => "inf" (QString) => inf (float).
+ float value = qInf();
+ QString valueAsString = QString::number(value);
+ QCOMPARE(valueAsString, QString::fromLatin1("inf"));
+ float valueFromString = valueAsString.toFloat();
+ QVERIFY(qIsInf(valueFromString));
+
+ // Check that -inf (float) => "-inf" (QString) => -inf (float).
+ value = -qInf();
+ valueAsString = QString::number(value);
+ QCOMPARE(valueAsString, QString::fromLatin1("-inf"));
+ valueFromString = valueAsString.toFloat();
+ QVERIFY(value == -qInf());
+ QVERIFY(qIsInf(valueFromString));
}
void tst_QString::arg_fillChar_data()