|
CX Framework
Cross-platform C utility framework
|
Functions | |
| uint8 * | _strnum_u64toa (uint8 buf[STRNUM_INTBUF], uint32 *len, uint64 value, uint16 base, uint32 mindigits, char sign, bool upper) |
| uint32 | _strnum_f64toa (float64 d, uint8 dest[STRNUM_FPBUF]) |
| uint32 | _strnum_f32toa (float32 f, uint8 dest[STRNUM_FPBUF]) |
| int32 | _strnum_grisu2_32 (float32 f, uint8 *digits, int32 *K) |
| int32 | _strnum_grisu2_64 (float64 d, uint8 *digits, int32 *K) |
Low-level helpers used by the format module and other internal components. They work with fixed-size buffers and return raw digit arrays. Most code should use the higher-level str* functions above.
| uint32 _strnum_f32toa | ( | float32 | f, |
| uint8 | dest[STRNUM_FPBUF] | ||
| ) |
Converts a 32-bit float to ASCII string
Like _strnum_f64toa(), but for single-precision floats.
| f | Float value to convert |
| dest | Buffer to write result (STRNUM_FPBUF bytes) |
| uint32 _strnum_f64toa | ( | float64 | d, |
| uint8 | dest[STRNUM_FPBUF] | ||
| ) |
Converts a 64-bit float to ASCII string
Internal function using Grisu2 algorithm. Automatically selects format (plain, decimal, or scientific notation) and handles special values.
| d | Double value to convert |
| dest | Buffer to write result (STRNUM_FPBUF bytes) |
| int32 _strnum_grisu2_32 | ( | float32 | f, |
| uint8 * | digits, | ||
| int32 * | K | ||
| ) |
Low-level Grisu2 algorithm for 32-bit float
Extracts decimal digits and exponent for a float. This is the core of the Grisu2 algorithm and is used internally by _strnum_f32toa().
| f | Float value to convert |
| digits | Buffer to receive decimal digits (no decimal point, 18 bytes) |
| K | Pointer to exponent value (input/output) |
| int32 _strnum_grisu2_64 | ( | float64 | d, |
| uint8 * | digits, | ||
| int32 * | K | ||
| ) |
Low-level Grisu2 algorithm for 64-bit double
Like _strnum_grisu2_32(), but for double-precision values.
| d | Double value to convert |
| digits | Buffer to receive decimal digits (no decimal point, 18 bytes) |
| K | Pointer to exponent value (input/output) |
| uint8 * _strnum_u64toa | ( | uint8 | buf[STRNUM_INTBUF], |
| uint32 * | len, | ||
| uint64 | value, | ||
| uint16 | base, | ||
| uint32 | mindigits, | ||
| char | sign, | ||
| bool | upper | ||
| ) |
Converts a 64-bit unsigned integer to ASCII digits
Internal function for integer formatting. Converts the value to the specified base and writes ASCII digits into the provided buffer, returning a pointer to the start of the converted string within the buffer.
| buf | Fixed-size buffer (STRNUM_INTBUF bytes) to write into |
| len | Optional pointer to receive the length of the result (excluding null terminator) |
| value | Value to convert |
| base | Numeric base (2-36) |
| mindigits | Minimum number of digits (zero-padded if necessary) |
| sign | Sign character to prepend (0 for none, '-' or '+' typically) |
| upper | If true, use uppercase letters for bases > 10; if false, use lowercase |