UCE Docs / to_f64

Signature

f64 to_f64(String s, f64 fallback = 0)

Parameters

s : string to parse
fallback : value returned when s is empty or not a complete floating-point number
return value : parsed f64, or fallback.

Parses a trimmed string as a floating-point number.

Unlike float_val(), the whole trimmed string must be consumed by the parser. Empty strings and partially parsed values such as "3.5ms" return the fallback.

Example

print(to_f64("3.5"), "\n");
Output
3.5