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 double string.

ExessResult exess_read_double(const char *str, double *out)

Read a double string 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 double has limited precision by definition.

Parameters:
  • str – String to read.

  • out – Parsed value, or NaN on error.

Returns:

The count of characters read, and a status.

ExessResult exess_write_double(double value, size_t buf_size, char *buf)

Write a canonical double string.

Any double value is supported. Reading the resulting string with exess_read_double() will produce exactly value, except the extra bits in NaNs aren’t preserved.

Parameters:
  • value – Value to write.

  • buf_size – Size of buf in bytes.

  • buf – Output buffer, or null to only measure.

Returns:

The count of characters in the output, and a status (ExessStatus.EXESS_SUCCESS, or ExessStatus.EXESS_NO_SPACE if the buffer is too small).