diff options
Diffstat (limited to 'src/corelib/tools/qlocale_p.h')
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index ac12f03356..917e83834a 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -56,9 +56,13 @@ #include "QtCore/qstring.h" #include "QtCore/qvarlengtharray.h" #include "QtCore/qvariant.h" +#include "QtCore/qnumeric.h" #include "qlocale.h" +#include <limits> +#include <cmath> + QT_BEGIN_NAMESPACE #ifndef QT_NO_SYSTEMLOCALE @@ -227,6 +231,19 @@ public: int width = -1, unsigned flags = NoFlags) const; + // this function is meant to be called with the result of stringToDouble or bytearrayToDouble + static float convertDoubleToFloat(double d, bool *ok) + { + if (qIsInf(d)) + return float(d); + if (std::fabs(d) > std::numeric_limits<float>::max()) { + if (ok != 0) + *ok = false; + return 0.0f; + } + return float(d); + } + double stringToDouble(const QChar *begin, int len, bool *ok, GroupSeparatorMode group_sep_mode) const; qint64 stringToLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; quint64 stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; |