FloatTryFromStr
Description
Parse a decimal string into a float. Supports an optional sign, decimal point, and scientific exponent.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:2884:
temp = StrInitFromCstr(start, token_len);
if (!FloatTryFromStr(&parsed, temp.data)) {
StrDeinit(&temp);
return start;- In
Float.c:52:
}
if (!FloatTryFromStr(&result, text)) {
LOG_FATAL("Failed to parse f32 conversion result");
}- In
Float.c:68:
}
if (!FloatTryFromStr(&result, text)) {
LOG_FATAL("Failed to parse f64 conversion result");
}- In
Float.c:273:
}
bool FloatTryFromStr(Float *out, const char *text) {
Float result = FloatInit();
Str digits = StrInit();- In
Float.c:379:
Float result = FloatInit();
(void)FloatTryFromStr(&result, text);
return result;
} Float parsed = FloatFromStr("12.3.4");
Float value = FloatInit();
bool result = !FloatTryFromStr(&value, "12.3.4");
result = result && FloatIsZero(&parsed); Float parsed = FloatFromStr(NULL);
Float value = FloatInit();
bool result = !FloatTryFromStr(&value, NULL);
result = result && FloatIsZero(&parsed);
Last updated on