Double¶
An xsd:double is an IEEE-754 64-bit floating point number, written in scientific notation.
Canonical form has no leading “+” sign, at most 1 leading or trailing zero such that there is at least 1 digit on either side of the decimal point, and always has an exponent, like “12.34E56”, “-1.0E-2”, and “-0.0E0”. The special values negative infinity, positive infinity, and not-a-number are written “-INF”, “INF”, and “NaN”, respectively.
Non-canonical form allows a leading “+”, any number of leading and trailing zeros, any number of digits (including zero) on either side of the point, and does not require an exponent or decimal point, like “+1E3”, “1E+3”, “.5E3”, “4.2”, and “42”.
-
ExessResult
exess_read_double(double *out, const char *str)¶ Read an xsd:double string after any leading whitespace.
Values beyond the range of
doublewill produce-INForINF.- Parameters
out – Set to the parsed value, or
NANon error.str – String input.
- Returns
The
countof characters read, and astatuscode.
-
ExessResult
exess_write_double(double value, size_t buf_size, char *buf)¶ Write a canonical xsd:double string.
Any
doublevalue is supported. Reading the resulting string withexess_read_double()will produce exactlyvalue, except the extra bits in NaNs are not preserved.- Parameters
value – Value to write.
buf_size – The size of
bufin bytes.buf – Output buffer, or null to only measure.
- Returns
The
countof characters in the output andstatusExessStatus.EXESS_SUCCESS, orExessStatus.EXESS_NO_SPACEif the buffer is too small.
-
EXESS_MAX_DOUBLE_LENGTH¶ The maximum length of a canonical xsd:double string, 24.