Decompose the specified value into constituent elements, loading the specified isNegative with a flag indicating if value is negative, the specified isExponentNegative with a flag indicating whether the exponent of value is negative, the specified integer with the integer portion of value, the specified fraction with the fraction portion of value, the specified exponent with the exponent portion of value, the specified significantDigits with the significant digits of value, the specified significantDigitsBias with a bias to add to the exponent when considering the value of the significant digits, and the significantDigitsDotOffset with the offset of the . character in significantDigits (if one exists). The returned significantDigits may include a . character (whose offset into significantDigits is given by significantDigitsOffset) which should simply be ignored when considering the significant digits. If significantDigits does not include a . character, significantDigitsOffset will be bsl::string_view::npos. The behavior is undefined unless NumberUtil::isValidNumber(value) is true. Note that if significantDigits[0] is 0 then value must be 0.
For example, here are some examples of decompose results for an input value (isNegative and isExpNegative are omitted for readability):
| value | int | frac | exp | sigDigit | sigDotOff | sigBias |
|----------|-------|-------|-----|----------|-----------|---------|
| "0.00" | "0" | "00" | "" | "0" | npos | 0 |
| "100e+1" | "100" | "" | "1" | "1" | npos | 2 |
| "0.020" | "0" | "020" | "" | "2" | npos | -2 |
| "1.12e5" | "1" | "12" | "5" | "1.12" | 1 | -2 |
| "34.50" | "34" | "50" | "" | "34.5" | 2 | -1 |
| "0.060" | "0" | "060" | "" | "6" | npos | -2 |
| "10e-2" | "0" | "1" | "2" | "1" | npos | 1 |
Notice that the . is ignored when considering significantDigits (so "34.5" is treated as "345", and the bias is -1).
Finally, note that significantDigits, significantDigitBias, and significantDigitsDotOffset are useful when considering a canonical representation for a JSON Number, which consists of a whole number (with leading and trailing zeros removed) and an exponent. This canonical representation can be used when determining whether two JSON numbers are equal. For example, "-12.30e-4" would have a canonical representation -123e-5. This canonical representation can be computed by taking the returned significantDigits, "12.3", ignoring the . character at significantDigitsOffset and incorporating isNegative to get the canonical significant digits -123, then combining exponent ("4") with isExponentNegative to get the exponent of -4 and then adding the returned significantDigitsBias of -1 to that exponent to get the canonical exponent of -5. Combining the canonical significant digits (-123) and the canonical exponent (-5) results in the canonical representation -123e-5.