facil.io

#./fio-stl/002 atol.h

49 public symbols.

#Macros

#FIO_ATOL_ALLOW_UNDERSCORE_DIVIDER

c
#define FIO_ATOL_ALLOW_UNDERSCORE_DIVIDER 1

Symbol type: macro

#FIO_MATH_DBL_MANT_MASK

c
#define FIO_MATH_DBL_MANT_MASK (((uint64_t)1ULL << 52) - 1)

Symbol type: macro

#FIO_MATH_DBL_EXPO_MASK

c
#define FIO_MATH_DBL_EXPO_MASK ((uint64_t)2047ULL << 52)

Symbol type: macro

#FIO_MATH_DBL_SIGN_MASK

c
#define FIO_MATH_DBL_SIGN_MASK ((uint64_t)1ULL << 63)

Symbol type: macro

#Types

#fio_aton_s

c
typedef struct {
union {
int64_t i;
double f;
uint64_t u;
};
int is_float;
int err;
} fio_aton_s

Result type for fio_aton

Symbol type: type

#Functions

#fio_aton

c
FIO_SFUNC fio_aton_s fio_aton(char **pstr)

Converts a String to a number - either an integer or a float (double).

Skips white space at the beginning of the string.

Auto detects binary and hex formats when prefix is provided (0x / 0b).

Auto detects octal when number starts with zero.

Auto detects the Strings "inf", "infinity" and "nan" as float values.

The number's format and type are returned in the return type.

If a numerical overflow or format error occurred, the .err flag is set.

Note: rounding errors may occur, as this is not an strtod exact match.

Symbol type: function

#fio_atol

c
int64_t fio_atol(char **pstr)

A helper function that converts between String data to a signed int64_t.

Numbers are assumed to be in base 10. Octal (0###), Hex (0x##/x##) and binary (0b##/ b##) are recognized as well. For binary Most Significant Bit must come first.

The most significant difference between this function and strtol (aside of API design), is the added support for binary representations.

Symbol type: function

#fio_atof

c
double fio_atof(char **pstr)

A helper function that converts between String data to a signed double.

Symbol type: function

#fio_ltoa

c
size_t fio_ltoa(char *dest, int64_t num, uint8_t base)

A helper function that writes a signed int64_t to a string.

No overflow guard is provided, make sure there's at least 68 bytes available (for base 2).

Offers special support for base 2 (binary), base 8 (octal), base 10 and base 16 (hex) where prefixes are automatically added if required (i.e.,"0x" for hex and "0b" for base 2, and "0" for octal).

Supports any base up to base 36 (using 0-9,A-Z).

An unsupported base will log an error and print zero.

Returns the number of bytes actually written (excluding the NUL terminator).

Symbol type: function

#fio_ftoa

c
size_t fio_ftoa(char *dest, double num, uint8_t base)

A helper function that converts between a double to a string.

No overflow guard is provided, make sure there's at least 130 bytes available (for base 2).

Supports base 2, base 10 and base 16. An unsupported base will silently default to base 10. Prefixes aren't added (i.e., no "0x" or "0b" at the beginning of the string).

Returns the number of bytes actually written (excluding the NUL terminator).

Symbol type: function

#fio_c2i

c
uint8_t fio_c2i(unsigned char c)

Maps characters to alphanumerical value, where numbers have their natural values (0-9) and A-Z (or a-z) are the values 10-35.

Out of bound values return 255.

This allows parsing of numeral strings for up to base 36.

Symbol type: function

#fio_i2c

c
uint8_t fio_i2c(unsigned char i)

Maps numeral values to alphanumerical characters, where numbers have their natural values (0-9) and A-Z are the values 10-35.

Accepts values up to 63. Returns zero for values over 35. Out of bound values produce undefined behavior.

This allows printing of numerals for up to base 36.

Symbol type: function

#fio_digits10

c
inline size_t fio_digits10(int64_t i)

Returns the number of digits in base 10.

Symbol type: function

#fio_digits10u

c
FIO_SFUNC size_t fio_digits10u(uint64_t i)

Returns the number of digits in base 10 for an unsigned number.

Symbol type: function

#fio_digits8u

c
FIO_SFUNC size_t fio_digits8u(uint64_t i)

Returns the number of digits in base 8 for an unsigned number.

Symbol type: function

#fio_digits16u

c
FIO_SFUNC size_t fio_digits16u(uint64_t i)

Returns the number of digits in base 16 for an unsigned number.

Symbol type: function

#fio_digits_bin

c
FIO_SFUNC size_t fio_digits_bin(uint64_t i)

Returns the number of digits in base 2 for an unsigned number.

Symbol type: function

#fio_digits_xbase

c
FIO_SFUNC size_t fio_digits_xbase(uint64_t i, size_t base)

Returns the number of digits in any base X<65 for an unsigned number.

Symbol type: function

#fio_ltoa10

c
inline void fio_ltoa10(char *dest, int64_t i, size_t digits)

Writes a signed number to dest using digits bytes (+ NUL)

Symbol type: function

#fio_atol10

c
int64_t fio_atol10(char **pstr)

Reads a signed base 10 formatted number.

Symbol type: function

#fio_ltoa10u

c
inline void fio_ltoa10u(char *dest, uint64_t i, size_t digits)

Writes unsigned number to dest using digits bytes (+ NUL)

Symbol type: function

#fio_ltoa16u

c
inline void fio_ltoa16u(char *dest, uint64_t i, size_t digits)

Writes unsigned number to dest using digits bytes (+ NUL)

Symbol type: function

#fio_ltoa_bin

c
inline void fio_ltoa_bin(char *dest, uint64_t i, size_t digits)

Writes unsigned number to dest using digits bytes (+ NUL)

Symbol type: function

#fio_ltoa_xbase

c
inline void fio_ltoa_xbase(char *dest, uint64_t i, size_t digits, size_t base)

Writes unsigned number to dest using digits bytes (+ NUL)

Symbol type: function

#fio_atol8u

c
uint64_t fio_atol8u(char **pstr)

Reads a signed base 8 formatted number - may overflow buffer.

Symbol type: function

#fio_atol10u

c
uint64_t fio_atol10u(char **pstr)

Reads a signed base 10 formatted number - may overflow buffer.

Symbol type: function

#fio_atol16u

c
uint64_t fio_atol16u(char **pstr)

Reads an unsigned hex formatted number (possibly prefixed with "0x").

Symbol type: function

#fio_atol_bin

c
uint64_t fio_atol_bin(char **pstr)

Reads an unsigned binary formatted number (possibly prefixed with "0b").

Symbol type: function

#fio_atol_xbase

c
uint64_t fio_atol_xbase(char **pstr, size_t base)

Read an unsigned number in any base up to base 36.

Symbol type: function

#fio_stol10u

c
uint64_t fio_stol10u(char **pos, const char *end)

Reads an unsigned base 10 number within [pos, end) - strict digits only (no whitespace, sign, underscores or prefixes). Advances pos past the digits consumed. On overflow sets errno == E2BIG and stops at the last valid digit. Callers detect empty / trailing junk by testing pos.

Symbol type: function

#fio_stol10

c
int64_t fio_stol10(char **pos, const char *end)

Reads a signed base 10 number within [pos, end) - an optional leading - / + followed by strict digits only. Sets errno == E2BIG on overflow (either the magnitude or the signed range limit).

Symbol type: function

#fio_stol16u

c
uint64_t fio_stol16u(char **pos, const char *end)

Reads an unsigned hex number within [pos, end) - strict hex digits only (NO 0x prefix, no underscores). Advances pos past the digits consumed. On overflow sets errno == E2BIG and stops at the last valid digit.

Symbol type: function

#fio_u2i_limit

c
inline int64_t fio_u2i_limit(uint64_t val, size_t invert)

Converts an unsigned val to a signed val, with overflow protection.

Symbol type: function

#fio_i2d

c
inline double fio_i2d(int64_t mant, int64_t exponent_in_base_2)

Converts a 64 bit integer to an IEEE 754 formatted double.

Symbol type: function

#fio_u2d

c
inline double fio_u2d(uint64_t mant, int64_t exponent_in_base_2)

Converts a 64 bit unsigned integer to an IEEE 754 formatted double.

Symbol type: function

#fio_u128_hex_read

c
fio_u128 fio_u128_hex_read(char **pstr)

Reads a hex numeral string and initializes the numeral.

Symbol type: function

#fio_u256_hex_read

c
fio_u256 fio_u256_hex_read(char **pstr)

Reads a hex numeral string and initializes the numeral.

Symbol type: function

#fio_u512_hex_read

c
fio_u512 fio_u512_hex_read(char **pstr)

Reads a hex numeral string and initializes the numeral.

Symbol type: function

#fio_u1024_hex_read

c
fio_u1024 fio_u1024_hex_read(char **pstr)

Reads a hex numeral string and initializes the numeral.

Symbol type: function

#fio_u2048_hex_read

c
fio_u2048 fio_u2048_hex_read(char **pstr)

Reads a hex numeral string and initializes the numeral.

Symbol type: function

#fio_u4096_hex_read

c
fio_u4096 fio_u4096_hex_read(char **pstr)

Reads a hex numeral string and initializes the numeral.

Symbol type: function

#fio_u128_hex_write

c
size_t fio_u128_hex_write(char *dest, const fio_u128 *)

Prints out the underlying 64 bit array (for debugging).

Symbol type: function

#fio_u256_hex_write

c
size_t fio_u256_hex_write(char *dest, const fio_u256 *)

Prints out the underlying 64 bit array (for debugging).

Symbol type: function

#fio_u512_hex_write

c
size_t fio_u512_hex_write(char *dest, const fio_u512 *)

Prints out the underlying 64 bit array (for debugging).

Symbol type: function

#fio_u1024_hex_write

c
size_t fio_u1024_hex_write(char *dest, const fio_u1024 *)

Prints out the underlying 64 bit array (for debugging).

Symbol type: function

#fio_u2048_hex_write

c
size_t fio_u2048_hex_write(char *dest, const fio_u2048 *)

Prints out the underlying 64 bit array (for debugging).

Symbol type: function

#fio_u4096_hex_write

c
size_t fio_u4096_hex_write(char *dest, const fio_u4096 *)

Prints out the underlying 64 bit array (for debugging).

Symbol type: function

#fio_ltoa8u

c
inline void fio_ltoa8u(char *dest, uint64_t i, size_t digits)

Symbol type: function

#fio_d2expo

c
inline int fio_d2expo(double d)

Symbol type: function