Provide an attribute class to configure decimal formatting.
More...
Detailed Description
- Outline
-
-
- Purpose:
- Provide an attribute class to configure decimal formatting.
-
- Classes:
-
- See also:
- Component bdldfp_decimalutil
-
- Description:
- This component provides a single, simply constrained (value-semantic) attribute class,
bdldfp::DecimalFormatConfig
, that is used to configure various aspects of decimal value formatting.
-
- Attributes:
Name Type Default Simple Constraints
--------- ------ --------------- ------------------
style Style e_NATURAL none
precision int 0 >= 0
sign Sign e_NEGATIVE_ONLY none
infinity string "inf" none
nan string "nan" none
snan string "snan" none
point char '.' none
exponent char 'e' none
showpoint bool false none
expwidth int 2 >= 1, <= 4
-
style
: control how the decimal number is written. If style
is e_SCIENTIFIC
, the number is written as its sign, then a single digit, then the decimal point, then precision
digits, then the exponent
character, then a -
or +
, then an exponent with no leading zeroes (with a zero exponent written as 0
). If style
is e_FIXED
, the number is written as its sign, then one or more digits, then the decimal point, then precision
digits. If the precision
value equals 0
then precision
digits and the decimal point are not written. If style
is e_NATURAL
, the number is written according to the description of to-scientific-string
found in http://speleotrove.com/decimal/decarith.pdf (and no other specified formatting values are used, including precision).
-
precision
: control how many digits are written after the decimal point if the decimal number is rendered in e_FIXED
and e_SCIENTIFIC
formats. Note that precision
attribute is ignored in e_NATURAL
format.
-
sign
: control how the sign is output. If a decimal value has its sign bit set, a -
is always written. Otherwise, if sign
is e_NEGATIVE_ONLY
, no sign is written. If it is e_ALWAYS
, a +
is written.
-
infinity
: specify a string to output infinity value.
-
nan
: specify a string to output NaN value.
-
snan
: specify a string to output signaling NaN value.
-
point
: specify the character to use for decimal points.
-
exponent
: specify the character to use for exponent when style
is e_SCIENTIFIC
or e_NATURAL
.
-
showpoint
: specify whether a decimal point is always displayed.
-
expwidth
: control the minimum number of digits used to write the exponent.