float

A float is an IEEE-754 32-bit floating point number, written in scientific notation.

The lexical form is the same as double, but the value space has less precision.

EXESS_MAX_FLOAT_LENGTH

15U

The maximum length of a canonical float string.

ExessResult exess_read_float(const char *str, float *out)

Read a float 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 float 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_float(float value, size_t buf_size, char *buf)

Write a canonical float string.

Any float value is supported. Reading the resulting string with exess_read_float() 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).