std.math
Width-suffixed f32 / f64 floating-point helpers.
std.math exposes a small set of floating-point helpers. Every function is width-suffixed: there is an _f32 and an _f64 form, because Zmeu does not implicitly promote between float widths. Pick the suffix that matches your value’s type.
Functions
Section titled “Functions”import std.math as math
export def sqrt_f32(value: f32) -> f32export def sqrt_f64(value: f64) -> f64
export def abs_f32(value: f32) -> f32export def abs_f64(value: f64) -> f64
export def floor_f32(value: f32) -> f32export def floor_f64(value: f64) -> f64
export def ceil_f32(value: f32) -> f32export def ceil_f64(value: f64) -> f64
export def trunc_f32(value: f32) -> f32export def trunc_f64(value: f64) -> f64
export def is_nan_f32(value: f32) -> boolexport def is_nan_f64(value: f64) -> bool
export def is_finite_f32(value: f32) -> boolexport def is_finite_f64(value: f64) -> boolThese map directly onto the native floating-point operations with default IEEE behaviour: there are no fast-math flags. sqrt of a negative produces nan; is_nan / is_finite classify the value without trapping.
Example
Section titled “Example”import std.math as math
def magnitude(x: f64, y: f64) -> f64: return math.sqrt_f64(x * x + y * y)- There is no implicit
f32↔f64conversion; cast explicitly withvalue as f64when you need to cross widths. - Trigonometric, logarithmic, and exponential functions are not in this slice yet: they will be added with the same width-suffixed convention.