Skip to content

float

The float module provides float conversion, rounding, and math utilities. It is auto-imported — no import statement needed.

FunctionSignatureDescription
to_string(Float) -> StringString representation
to_int(Float) -> IntTruncate toward zero
from_int(Int) -> FloatConvert integer to float
parse(String) -> Result[Float, String]Parse string to float
to_fixed(Float, Int) -> StringFormat with fixed decimal places
FunctionSignatureDescription
round(Float) -> FloatRound to nearest integer
floor(Float) -> FloatRound down
ceil(Float) -> FloatRound up
FunctionSignatureDescription
abs(Float) -> FloatAbsolute value
sqrt(Float) -> FloatSquare root
min(Float, Float) -> FloatSmaller of two
max(Float, Float) -> FloatLarger of two
clamp(Float, Float, Float) -> FloatClamp to range [lo, hi]
sign(Float) -> FloatSign: -1.0, 0.0, or 1.0
FunctionSignatureDescription
is_nan(Float) -> BoolCheck if NaN
is_infinite(Float) -> BoolCheck if infinite
float.to_string(3.14) // => "3.14"
float.to_int(3.9) // => 3
float.round(3.6) // => 4.0
float.parse("3.14") // => ok(3.14)
float.to_fixed(3.14159, 2) // => "3.14"
float.abs(-2.5) // => 2.5
float.clamp(15.0, 0.0, 10.0)// => 10.0