std/math
Mathematical functions and constants.
milo
from "std/math" import { Math }API reference
Math
milo
pub struct MathMath.abs
milo
fn Math.abs(x: f64): f64Math.absI32
milo
fn Math.absI32(x: i32): i32Math.absI64
milo
fn Math.absI64(x: i64): i64Math.acos
milo
fn Math.acos(x: f64): f64Clamped before the call. Round-off in a dot product routinely lands a cosine at 1.0000000000000002, and libm's acos returns NaN there rather than 0 — a NaN that then propagates silently through an angle calculation.
Math.asin
milo
fn Math.asin(x: f64): f64Math.atan
milo
fn Math.atan(x: f64): f64Math.atan2
milo
fn Math.atan2(y: f64, x: f64): f64Math.ceil
milo
fn Math.ceil(x: f64): f64Math.clampF64
milo
fn Math.clampF64(x: f64, lo: f64, hi: f64): f64Math.clampI64
milo
fn Math.clampI64(x: i64, lo: i64, hi: i64): i64Math.cos
milo
fn Math.cos(x: f64): f64Math.e
milo
fn Math.e(): f64Math.exp
milo
fn Math.exp(x: f64): f64Math.floor
milo
fn Math.floor(x: f64): f64Math.inf
milo
fn Math.inf(): f64Math.isFinite
milo
fn Math.isFinite(x: f64): boolMath.isInf
milo
fn Math.isInf(x: f64): boolMath.isNan
milo
fn Math.isNan(x: f64): boolNaN is the only value not equal to itself, so this is the one reliable test — x == f64.NAN is always false (the compiler lints that mistake).
Math.log
milo
fn Math.log(x: f64): f64Math.log10
milo
fn Math.log10(x: f64): f64Math.log2
milo
fn Math.log2(x: f64): f64Math.max
milo
fn Math.max<T>(a: T, b: T): TThe larger of two values of any one type with >. See Math.min.
Math.maxF64
milo
fn Math.maxF64(a: f64, b: f64): f64Math.maxI32
milo
fn Math.maxI32(a: i32, b: i32): i32Math.maxI64
milo
fn Math.maxI64(a: i64, b: i64): i64Math.min
milo
fn Math.min<T>(a: T, b: T): TThe smaller of two values of any one type with <: Math.min(x, 1.0) on f64, Math.min(n, 10) on an int of any width. A literal takes the other argument's type. NaN is not ordered, so a NaN a yields b (as minF64 does).
Math.minF64
milo
fn Math.minF64(a: f64, b: f64): f64Math.minI32
milo
fn Math.minI32(a: i32, b: i32): i32Math.minI64
milo
fn Math.minI64(a: i64, b: i64): i64Math.mod
milo
fn Math.mod(x: f64, y: f64): f64Math.pi
milo
fn Math.pi(): f64Math.pow
milo
fn Math.pow(base: f64, exponent: f64): f64Math.round
milo
fn Math.round(x: f64): f64Math.sin
milo
fn Math.sin(x: f64): f64Math.sqrt
milo
fn Math.sqrt(x: f64): f64Math.tan
milo
fn Math.tan(x: f64): f64