f32
lib callCapy
function f32(value : bool, opt : any = {}) f32
function f32(value : any, opt : any = {}) f32
function f32(value : as string, opt : any = {}) f32f32() converts finite text to a 32-bit floating-point value. Invalid, non-finite, or out-of-range text returns opt.fallback. The default fallback is 0.0.
An any value that holds a number converts without text. The result is the same as the result for the text of that number. true converts to 1 and false to 0, also inside an any.
A one-argument numeric conversion rounds directly to f32. Integers above 2^24 can lose precision. For example, f32(16777217) becomes 16777216.
Text conversion trims surrounding whitespace and accepts decimal exponents. It requires a complete finite number. For example, f32("3.5x", fallback: 9.0) returns 9.0. Text outside the finite f32 range uses the fallback. An integer constructor such as s64 truncates a fraction instead of preserving it.
print(f32("1.5"), "\n")
Output
1.5Parameters
value : scalar value or text to convert
opt : options map with fallback
Return Values
A 32-bit floating-point value, or opt.fallback.