summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-01-05 14:17:34 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-01-07 10:37:53 +0000
commitfe4cc2793f80e285be66c36bc1ec6903ddcd312e (patch)
tree67150e990da5dd759d9d33e6f6bb19df8e275946 /src
parenteac9e74d9271f793f2a49af6ba776dd444875844 (diff)
Documentation: Clarify the meaning of the precision parameter for double formatting
Move it to the table for QLocale::toString() to make it more prominent. Explain the meaning for QTextStream::realNumberPrecision(). Pick-to: 6.5 6.4 6.2 Change-Id: Ic2da22ff6bea09e79e17f19b4636cef35dc3a615 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/serialization/qtextstream.cpp7
-rw-r--r--src/corelib/text/qlocale.cpp22
2 files changed, 14 insertions, 15 deletions
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index a268002dc6..83e97c834d 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -1400,7 +1400,8 @@ QTextStream::RealNumberNotation QTextStream::realNumberNotation() const
/*!
Sets the precision of real numbers to \a precision. This value
describes the number of fraction digits QTextStream should
- write when generating real numbers.
+ write when generating real numbers (FixedNotation, ScientificNotation), or
+ the maximum number of significant digits (SmartNotation).
The precision cannot be a negative value. The default value is 6.
@@ -1419,7 +1420,9 @@ void QTextStream::setRealNumberPrecision(int precision)
/*!
Returns the current real number precision, or the number of fraction
- digits QTextStream will write when generating real numbers.
+ digits QTextStream will write when generating real numbers
+ (FixedNotation, ScientificNotation), or the maximum number of significant
+ digits (SmartNotation).
\sa setRealNumberNotation(), realNumberNotation(), numberFlags(), integerBase()
*/
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index cf79ed901f..1668452497 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -2618,21 +2618,17 @@ static bool qIsUpper(char c)
The \a format defaults to \c{'g'}. It can be any of the following:
\table
- \header \li Format \li Meaning
- \row \li \c 'e' \li format as [-]9.9e[+|-]999
- \row \li \c 'E' \li format as [-]9.9E[+|-]999
- \row \li \c 'f' \li format as [-]9.9
- \row \li \c 'F' \li same as \c 'f' except for INF and NAN (see below)
- \row \li \c 'g' \li use \c 'e' or \c 'f' format, whichever is more concise
- \row \li \c 'G' \li use \c 'E' or \c 'F' format, whichever is more concise
+ \header \li Format \li Meaning \li Meaning of \a precision
+ \row \li \c 'e' \li format as [-]9.9e[+|-]999 \li number of digits \e after the decimal point
+ \row \li \c 'E' \li format as [-]9.9E[+|-]999 \li "
+ \row \li \c 'f' \li format as [-]9.9 \li "
+ \row \li \c 'F' \li same as \c 'f' except for INF and NAN (see below) \li "
+ \row \li \c 'g' \li use \c 'e' or \c 'f' format, whichever is more concise \li maximum number of significant digits (trailing zeroes are omitted)
+ \row \li \c 'G' \li use \c 'E' or \c 'F' format, whichever is more concise \li "
\endtable
- For the \c 'e', \c 'E', \c 'f' and \c 'F' formats, the \a precision
- represents the number of digits \e after the decimal point. For the \c 'g'
- and \c 'G' formats, the \a precision represents the maximum number of
- significant digits (trailing zeroes are omitted). The special \a precision
- value QLocale::FloatingPointShortest selects the shortest representation
- that, when read as a number, gets back the original floating-point
+ The special \a precision value QLocale::FloatingPointShortest selects the
+ shortest representation that, when read as a number, gets back the original floating-point
value. Aside from that, any negative \a precision is ignored in favor of the
default, 6.