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().

Change-Id: Ic2da22ff6bea09e79e17f19b4636cef35dc3a615
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fe4cc2793f80e285be66c36bc1ec6903ddcd312e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Friedemann Kleint 2023-01-05 14:17:34 +01:00 committed by Qt Cherry-pick Bot
parent 03da3363a8
commit 8d7227460f
2 changed files with 14 additions and 15 deletions

View File

@ -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()
*/

View File

@ -2613,21 +2613,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.