String module

parse_float

procedure · 1 overloadSource

Reads the next token as a decimal number. The second result is false when the token is not entirely a number, or there is none.

parse_float :: (
    line: *string,
    delimiters := DEFAULT_DELIMITERS,
    spaces := DEFAULT_SPACES
) -> (value: float, success: bool)

Parameters

line: *string
delimiters := DEFAULT_DELIMITERS
spaces := DEFAULT_SPACES

Returns

value: float
success: bool
ExampleOpen in playground ↗
line := "2.5 rest";
value, ok := parse_float(*line);
assert(ok && value == 2.5);

See also