ludic/docs/language/text/text-to_float.md

827 B

id name category kind tokens sig tip order ns member
text-to_float Text.to_float text namespace-method Text.to_float Text.to_float(s) -> float Parse a leading decimal number from a string. 11 Text to_float

Reads an optional sign, the leading digits, a decimal point and an exponent from s and returns them as a float, stopping at the first character that cannot continue a number - so Text.to_float("0.25 m") is 0.25. A string with no leading number yields 0.0. It is the float twin of Text.to_int, for reading a data file or a typed value.

Parameters:

  • s — the string to parse
program ParseSpeed {
  let typed: string = "3.2"

  handler Apply phase Update {
    let speed = Text.to_float(typed)   # 3.2
  }
}