double¶
A 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 doesn’t require an exponent or decimal point, like “+1E3”, “1E+3”, “.5E3”, “4.2”, and “42”.
-
EXESS_MAX_DOUBLE_LENGTH¶
24U
The maximum length of a canonical
doublestring.
-
ExessResult exess_read_double(const char *str, double *out)¶
Read a
doublestring after any leading whitespace.Values too large (in absolute terms) to store will produce infinity, values too small will produce zero, and insignificant digits may be discarded. Note that these cases are considered successful since the value space of
doublehas limited precision by definition.- Parameters:
str – String to read.
out – Parsed value, or NaN on error.
- Returns:
The
countof characters read, and astatus.
-
ExessResult exess_write_double(double value, size_t buf_size, char *buf)¶
Write a canonical
doublestring.Any
doublevalue is supported. Reading the resulting string withexess_read_double()will produce exactlyvalue, except the extra bits in NaNs aren’t preserved.- Parameters:
value – Value to write.
buf_size – Size of
bufin bytes.buf – Output buffer, or null to only measure.
- Returns:
The
countof characters in the output, and astatus(ExessStatus.EXESS_SUCCESS, orExessStatus.EXESS_NO_SPACEif the buffer is too small).