summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text')
-rw-r--r--src/corelib/text/qlocale_p.h23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h
index ee0a28e94ec..fb312c5dfb9 100644
--- a/src/corelib/text/qlocale_p.h
+++ b/src/corelib/text/qlocale_p.h
@@ -18,10 +18,10 @@
#include "qlocale.h"
-#include <QtCore/private/qglobal_p.h>
#include <QtCore/qcalendar.h>
#include <QtCore/qlist.h>
#include <QtCore/qnumeric.h>
+#include <QtCore/private/qnumeric_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvarlengtharray.h>
@@ -304,23 +304,14 @@ public:
unsigned flags = NoFlags) const;
// this function is meant to be called with the result of stringToDouble or bytearrayToDouble
+ // so *ok must have been properly set (if not null)
[[nodiscard]] static float convertDoubleToFloat(double d, bool *ok)
{
- if (qIsInf(d))
- return float(d);
- if (std::fabs(d) > (std::numeric_limits<float>::max)()) {
- if (ok)
- *ok = false;
- const float huge = std::numeric_limits<float>::infinity();
- return d < 0 ? -huge : huge;
- }
- if (d != 0 && float(d) == 0) {
- // Values that underflow double already failed. Match them:
- if (ok)
- *ok = false;
- return 0;
- }
- return float(d);
+ float result;
+ bool b = convertDoubleTo<float>(d, &result);
+ if (ok && *ok)
+ *ok = b;
+ return result;
}
[[nodiscard]] double stringToDouble(QStringView str, bool *ok,