BloombergLP::bdldfp::DecimalFormatConfig::DecimalFormatConfig

Create an object of this class having the specified precision to control how many digits are written after a decimal point.

Synopsis

Declared in <bdldfp_decimalformatconfig.h>

explicit
DecimalFormatConfig(
    int precision,
    Style style = e_NATURAL,
    Sign sign = e_NEGATIVE_ONLY,
    char const* infinity = "inf",
    char const* nan = "nan",
    char const* snan = "snan",
    char point = '.',
    char exponent = 'e',
    bool showpoint = false,
    int expWidth = 2);

Description

The behavior is undefined unless precision >= -1. Optionally specify style to control how the number is written. If it is not specified, e_NATURAL is used. Optionally specify sign to control how the sign is output. If is not specified, e_NEGATIVE_ONLY is used. Optionally specify infinity as a string to output infinity value. If it is not specified, "inf" is used. Optionally specify nan as a string to output NaN value. If it is not specified, "nan" is used. Optionally specify snan as a string to output signaling NaN value. If it is not specified, "snan" is used. The behavior is undefined unless the pointers to infinity, nan and snan remain valid for the lifetime of this object. Optionally specify point as the character to use for decimal points. If it is not specified, . is used. Optionally specify exponent as the character to use for exponent. If it is not specified, e is used. Optionally specify showpoint to force a decimal point to always be written. Optionally specify expWidth to force at least that many digits to be written for an exponent, up to the number of digits in the largest supported exponent. If it is not specified, 2 is used. The behavior is undefined unless expWidth is 1, 2, 3, or 4. See the section for information on the class attributes.

Parameters

NameDescription
precisionnumber of digits written after the decimal point
stylehow the decimal number is written
signhow the sign is output
infinitystring used to output an infinity value
nanstring used to output a NaN value
snanstring used to output a signaling NaN value
pointcharacter used for decimal points
exponentcharacter used for the exponent
showpointwhether a decimal point is always displayed
expWidthminimum number of digits used to write the exponent