Skip to content

Search

Documentation

math

Deterministic float maths backed by pure-Rust libm: the same inputs give the same bits on every platform.

On this page

Deterministic float maths backed by pure-Rust libm: the same inputs give the same bits on every platform.

24 functions, 3 constants. Scripts reach it as math::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
abs(float) -> float — The magnitude, with the sign dropped.
acos(float) -> float — The angle in radians whose cosine is the argument, from 0 to PI; NaN outside -1..1.
asin(float) -> float — The angle in radians whose sine is the argument, from -PI/2 to PI/2; NaN outside -1..1.
atan(float) -> float — The angle in radians whose tangent is the argument, from -PI/2 to PI/2.
atan2(float, float) -> float — The angle in radians from the positive x axis to the point, taking y first and x second.
ceil(float) -> float — The smallest whole number at or above the argument, still a float.
clamp(float, float, float) -> float — The first argument held inside the range given by the second (low) and third (high).
cos(float) -> float — The cosine of an angle in radians.
cosh(float) -> float — The hyperbolic cosine.
exp(float) -> float — e raised to the given power.
floor(float) -> float — The largest whole number at or below the argument, still a float.
log(float) -> float — The natural logarithm; -INF at zero and NaN below it.
log10(float) -> float — The base-10 logarithm; -INF at zero and NaN below it.
max(float, float) -> float — The larger of two numbers.
min(float, float) -> float — The smaller of two numbers.
pow(float, float) -> float — The first argument raised to the power of the second.
round(float) -> float — The nearest whole number, with halfway cases going away from zero.
sin(float) -> float — The sine of an angle in radians.
sinh(float) -> float — The hyperbolic sine.
sqrt(float) -> float — The square root; NaN for a negative argument.
tan(float) -> float — The tangent of an angle in radians.
tanh(float) -> float — The hyperbolic tangent, between -1 and 1.
to_degrees(float) -> float — Radians converted to degrees.
to_radians(float) -> float — Degrees converted to radians.

Constants

name value
INFINITY inf
PI 3.141592653589793
TAU 6.283185307179586

Are you sure?