diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-11-19 16:27:03 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-11-23 10:05:06 +0000 |
commit | a9923674030980706940b3ee11145c38674bb35d (patch) | |
tree | 0fbc5b2b8e2eb4afa0f4e11f0ceeea013d2a81f6 /src/corelib/tools/qbytearray.cpp | |
parent | 704137f8de49a55a1b21bb6d612d2594562f51ce (diff) |
Change documentation of some toDouble()s to reflect reality
They actually return infinity if conversion overflows, while still
setting ok to false; they were documented to return 0 on failure, with
no mention of this special handling of overflow. Documented reality
rather than changing the behavior. Gave underflow as an example of
failure other than overflow (toDouble()s do indeed fail on it).
Added some tests of out-of-range values, infinities and NaNs.
[ChangeLog][QtCore][toDouble] QString, QByteArray and QLocale return
an infinity on overflow (since 5.7), while setting ok to false; this
was at odds with their documented behavior of returning 0 on failure.
The documentation now reflects the actual behavior.
Fixes: QTBUG-71256
Change-Id: I8d7e80ba1f06091cf0f1480c341553381103703b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 424420204a..1b7a4366c7 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -3871,7 +3871,8 @@ ushort QByteArray::toUShort(bool *ok, int base) const /*! Returns the byte array converted to a \c double value. - Returns 0.0 if the conversion fails. + Returns an infinity if the conversion overflows or 0.0 if the + conversion fails for other reasons (e.g. underflow). If \a ok is not \c nullptr, failure is reported by setting *\a{ok} to \c false, and success by setting *\a{ok} to \c true. |