Produce an object of the indicated return type by parsing the specified input string that represents a floating‐point number (written in either fixed or scientific notation). Optionally specify status in which to load a bit mask of additional status information. The resulting decimal object is initialized as follows:
Synopsis
Declared in <bdldfp_decimalimputil.h>
static
DecimalImpUtil::ValueType128
parse128(
char const* input,
unsigned int* status);
Description
* If input does not represent a floating‐point value, then return a decimal object of the indicated return type initialized to a NaN. * Otherwise if input represents infinity (positive or negative), as case‐insensitive "Inf" or "Infinity" string, then return a decimal object of the indicated return type initialized to infinity value with the same sign. * Otherwise if input 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 std::numeric_limits<Decimal32>::max() then store the value of the macro ERANGE into errno and return a decimal object of the indicated return type initialized to infinity with the same sign. * Otherwise if input represents a value that has an absolute value that is smaller than std::numeric_limits<Decimal32>::min(), then store the value of the macro ERANGE into errno and return a decimal object of the indicated return type initialized to zero with the same sign. * Otherwise if input has a value that is not exactly representable using std::numeric_limits<Decimal32>::max_digit decimal digits then return a decimal object of the indicated return type initialized to the value represented by input rounded according to the rounding direction. * Otherwise return a decimal object of the indicated return type initialized to the decimal value representation of input.
The *status, if supplied, mest be 0, and may be loaded with a bit mask of k_STATUS_INEXACT, k_STATUS_UNDERFLOW, and k_STATUS_OVERFLOW indicating wether the conversion from text was inexact, underflowed, or overflowed (or some combination) respectively. The behavior is undefined unless *status (if supplied) is 0.
Note that the parsing follows the rules as specified for the strtod32 function in section 9.6 of the ISO/EIC TR 24732 C Decimal Floating‐Point Technical Report.
Also note that the quanta of the resultant value is determined by the number of decimal places starting with the most significand digit in input string and cannot exceed the maximum number of digits necessary to differentiate all values of the indicated return type, for example:
` 'parse32("0.015") => 15e‐3' 'parse32("1.5") => 15e‐1' 'parse32("1.500") => 1500e‐3' 'parse32("1.2345678) => 1234568e‐6' ` Parse a 128‐bit decimal value from the specified input string.
Created with MrDocs