main-apidocs-libatomvm-src-unlocalized-dot-h.md
Include dependency graph for unlocalized.h:
digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "4" [label="term_typedef.h" tooltip="term_typedef.h"] "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/unlocalized.h" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/unlocalized.h" fillcolor="#BFBFBF"] "5" [label="assert.h" tooltip="assert.h"] "7" [label="inttypes.h" tooltip="inttypes.h"] "6" [label="limits.h" tooltip="limits.h"] "2" [label="stdbool.h" tooltip="stdbool.h"] "3" [label="stddef.h" tooltip="stddef.h"] "8" [label="stdint.h" tooltip="stdint.h"] "4" -> "5" [dir=forward tooltip="include"] "4" -> "6" [dir=forward tooltip="include"] "4" -> "7" [dir=forward tooltip="include"] "4" -> "8" [dir=forward tooltip="include"] "1" -> "2" [dir=forward tooltip="include"] "1" -> "3" [dir=forward tooltip="include"] "1" -> "4" [dir=forward tooltip="include"] }
This graph shows which files directly or indirectly include unlocalized.h:
digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "2" [label="/__w/AtomVM/AtomVM/src/libAtomVM/float_utils.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/float_utils.c"] "3" [label="/__w/AtomVM/AtomVM/src/libAtomVM/nifs.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/nifs.c"] "4" [label="/__w/AtomVM/AtomVM/src/libAtomVM/unlocalized.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/unlocalized.c"] "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/unlocalized.h" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/unlocalized.h" fillcolor="#BFBFBF"] "1" -> "2" [dir=back tooltip="include"] "1" -> "3" [dir=back tooltip="include"] "1" -> "4" [dir=back tooltip="include"] }
Locale-independent functions for floating-point numbers.
Provides formatting and parsing of floating-point numbers that always use ‘.’ as the decimal separator regardless of LC_NUMERIC. Thread-safe when snprintf_l()/strtod_l() or uselocale() is available. On pure C99 platforms, best-effort assuming no concurrent setlocale().
Defines
UNLOCALIZED_ENABLE_DOUBLE_API
Functions
int unlocalized_snprintf(char *buf, size_t size, const char *fmt, ...)
Locale-independent snprintf.
Behaves like snprintf but always uses ‘.’ as decimal separator regardless of LC_NUMERIC for floating-point conversions.
bool unlocalized_validate_bare_float_format(const char buf[], size_t len)
Validate strict bare decimal float format.
Checks that buf[0..len-1] matches the grammar: [+|-] DIGITS “.” DIGITS [(“e”|”E”) [+|-] DIGITS] where DIGITS is one or more ‘0’-‘9’ characters.
Rejects hex floats, inf, nan, whitespace, commas, and any other characters not in the grammar.
Parameters:
buf – pointer to the character data (need not be null-terminated)
len – number of characters to validate
Returns:
true if the format is valid, false otherwise
int unlocalized_strtod(const char buf[], size_t len, double *result)
Parse a double from a string locale-independently with strict validation.
Validates the input against the bare float format (see unlocalized_validate_bare_float_format), then parses with strtod using ‘.’ as decimal separator regardless of LC_NUMERIC. Rejects overflow (inf) but allows underflow (returns 0.0).
Parameters:
buf – pointer to the character data (need not be null-terminated)
len – number of characters to parse (max 255)
result – [out] on success, the parsed double value
Returns:
0 on success, -1 on error (caller should raise badarg)
static inline int unlocalized_strto_avm_float(const char buf[], size_t len, avm_float_t *result)
Parse an avm_float_t from a string locale-independently.
Dispatches to unlocalized_strtod or unlocalized_strtof depending on AVM_USE_SINGLE_PRECISION.