Produce an object of the indicated return type by parsing the specified str having the specified len excluding the terminating null character that represents a floating‐point number written in both fixed and scientific notations. These user‐defined literal suffixes can be applied to both numeric and string literals, (i.e., 1.2_d128, "1.2"_d64 or "inf"_d64). The resulting decimal object is initialized as follows:

Synopsis

Declared in <bdldfp_decimal.h>

bdldfp::Decimal64
operator""_d64(char const* str);

Description

* If str does not represent a floating‐point value, then return a decimal object of the indicated return type initialized to a NaN. * Otherwise if str represents infinity (positive or negative), then return a decimal object of the indicated return type initialized to infinity value with the same sign. * Otherwise if str represents zero (positive or negative), then return a decimal object of the indicated return type initialized to zero with the same sign. * Otherwise if str represents a value that has an absolute value that is larger than the maximum value supported by the indicated return type, then store the value of the macro ERANGE into errno and return a decimal object of the return type initialized to infinity with the same sign. * Otherwise if str represents a value that has an absolute value that is smaller than min value of the indicated return type, then store the value of the macro ERANGE into errno and return a decimal object of the return type initialized to zero with the same sign. * Otherwise if str has a value that is not exactly representable using the maximum digit number supported by the indicated return type, then return a decimal object of the return type initialized to the value represented by str rounded according to the rounding direction. * Otherwise return a decimal object of the indicated return type initialized to the decimal value representation of str.

Note that the parsing follows the rules as specified for the strtod64 function in section 9.6 of the ISO/EIC TR 247128 C Decimal Floating‐Point Technical Report.

Also note that the numeric literal version omits the optional leading sign in str. For example, if the string is ‐1.2_d64 then the string "1.2" is passed to the one‐argument form, not "‐1.2", because leading signs are operators, not parts of literals. On the other hand, the string literal version does not omit leading sign and if the string is "‐1.2"_d64 then the string "‐1.2" is passed to the two‐argument form.

Also note that the quantum of the resultant value is affected by the number of decimal places in str string in both numeric and string literal formats starting with the most significand digit and cannot exceed the maximum number of digits necessary to differentiate all values of the indicated return type, for example:

0.015_d64; => 15e‐3 1.5_d64; => 15e‐1 1.500_d64; => 1500e‐3 1.2345678901234567_d64; => 1234567890123458‐15

Created with MrDocs