std::mathMathematical operations.
Generic numeric functions (absolute value, min, max), integer helpers (clamp, sign), floating-point functions (sqrt, pow, floor, ceil, round), and transcendentals (exp, log, sin, cos) plus common constants.
Generic numeric and floating-point functions are lowered to LLVM math ops by
the codegen backend. Integer-only helpers and constants are
implemented directly in Hew. The Rust crate in src/lib.rs remains only
as a workspace build placeholder.
import std::math;
fn main() {
println(math.abs(-5)); // 5
println(math.clamp(10, 0, 5)); // 5
println(math.sqrt(4.0)); // 2
println(math.pi()); // 3.14159
}
piThe ratio of a circle's circumference to its diameter.
eEuler's number, the base of natural logarithms.
absReturn the absolute value of a numeric value.
minReturn the smaller of two numeric values.
maxReturn the larger of two numeric values.
clampClamp x to the range [lo, hi].
signReturn the sign of an integer: -1, 0, or 1.
sqrtReturn the square root of a float.
powRaise base to the power exp.
floorReturn the largest integer value less than or equal to x.
ceilReturn the smallest integer value greater than or equal to x.
roundRound to the nearest integer, with ties rounding away from zero.
expReturn e raised to the power x.
logReturn the natural logarithm of x.
sinReturn the sine of x (radians).
cosReturn the cosine of x (radians).