Capy-Bearer Documentation

f64

lib call

Capy

function f64(value : as string, opt : any = {}) f64

f64() converts the exact text from value to a floating-point value. The value must contain a complete decimal number. opt.fallback is the result for empty text or text that does not parse. It defaults to 0.0.

value accepts scalar values through as string. The conversion keeps scalar text exact. Empty and missing any values both convert to empty text. Use value? before conversion when presence matters. An empty value is present, but a missing value is not.

The options map accepts only fallback. An unknown key, including base, is an error.

A one-argument numeric conversion rounds directly to f64. Integers above 2^53 can lose precision. Use an integer type when every integer digit must remain exact.

Text conversion trims surrounding whitespace and accepts decimal exponents. It requires a complete finite number. For example, f64("3.5x", fallback: 9.0) returns 9.0. An integer constructor such as s64 truncates a fraction instead of preserving it.

print(f64("3.5"), "\n")
print(f64("not a number", fallback: 9.0), "\n")

Output

3.5
9

Parameters

value : scalar value or text to convert

opt : options map with fallback

Return Values

An f64 value, or opt.fallback.