Library / Numbers / Math / Math
Math
NAMESPACE of standard math functions and constants.
Fields 7
float64 PIfloat64 TAUfloat64 Efloat64 PHIfloat64 EMfloat64 SQRT2float64 LN2Methods 40
METHOD abs(int32 x) RETURNS int32reads
ABSOLUTE VALUE — overloads per primitive
METHOD abs(float64 x) RETURNS float64reads
METHOD isNaN(float64 x) RETURNS booleanreads
TRUE iff x is NaN — the only value not equal to itself. The language
forbids authoring NaN as a literal (a NaN/Infinity is a computation
RESULT, never developer-assignable, I.C), so this is how a value that
can ARISE is TESTED — retiring the hand-rolled v != v idiom.
METHOD isNaN(float32 x) RETURNS booleanreads
METHOD isFinite(float64 x) RETURNS booleanreads
TRUE iff x is finite (neither ±infinity nor NaN). x - x is 0 for any
finite x and NaN for ±inf/NaN, so (x - x) == 0 is the finiteness test —
retiring the hand-rolled (f - f) == 0 idiom.
METHOD isFinite(float32 x) RETURNS booleanreads
METHOD squareRoot(float64 x) RETURNS complexreads
Square root over the reals AND into the complex plane — RETURNS complex
so a negative argument yields a pure-imaginary result instead of failing:
squareRoot(9) = (3 + 0im) (x ≥ 0 → real component)
squareRoot(-4) = (0 + 2im) (x < 0 → imaginary component)
This is the Math↔complex integration: complex c = Math.squareRoot(-4)
is a plain complex assignment. (Math depends on the complex type here; the
edge is one-way — Complex's own magnitude/phase use the bare FOREIGN math
binds, not this namespace, so there is no Math↔Complex cycle.)
METHOD cubeRoot(float64 x) RETURNS float64reads
METHOD exponent(float64 base, float64 exp) RETURNS | float64reads
METHOD eulersExponent(float64 x) RETURNS float64reads
METHOD loge(float64 x) RETURNS | float64reads
LOGARITHMS — x must be > 0; FAILURE STATUS otherwise.
METHOD log2(float64 x) RETURNS | float64reads
METHOD log10(float64 x) RETURNS | float64reads
METHOD sin(float64 x) RETURNS float64reads
TRIGONOMETRY — radians; asin/acos domain-checked.
METHOD cos(float64 x) RETURNS float64reads
METHOD tan(float64 x) RETURNS float64reads
METHOD asin(float64 x) RETURNS | float64reads
METHOD acos(float64 x) RETURNS | float64reads
METHOD atan(float64 x) RETURNS float64reads
METHOD atan2(float64 y, float64 x) RETURNS float64reads
METHOD sinh(float64 x) RETURNS float64reads
METHOD cosh(float64 x) RETURNS float64reads
METHOD tanh(float64 x) RETURNS float64reads
METHOD floor(float64 x) RETURNS float64reads
ROUNDING — float64 in, float64 out
METHOD ceiling(float64 x) RETURNS float64reads
METHOD round(float64 x) RETURNS float64reads
METHOD truncate(float64 x) RETURNS float64reads
METHOD sign(int32 x) RETURNS int32reads
SIGN — returns -1, 0, or 1 as int32 regardless of input type
METHOD sign(float64 x) RETURNS int32reads
METHOD min(int32 a, int32 b) RETURNS int32reads
MIN / MAX / CLAMP — overloads per numeric primitive
Spelled out for int32 + float64 in this preview; production Math.ev expands int64 / float32 variants identically.
METHOD min(float64 a, float64 b) RETURNS float64reads
METHOD max(int32 a, int32 b) RETURNS int32reads
METHOD max(float64 a, float64 b) RETURNS float64reads
METHOD clamp(int32 v, int32 lo, int32 hi) RETURNS int32reads
METHOD clamp(float64 v, float64 lo, float64 hi) RETURNS float64reads
METHOD toRadians(float64 deg) RETURNS float64reads
ANGLE CONVERSION
METHOD toDegrees(float64 rad) RETURNS float64reads
METHOD saturatingAdd(int32 a, int32 b) RETURNS int32reads
OVERFLOW-AWARE INTEGER ARITHMETIC
Two flavors per integer primitive (the WRAPPING flavor is now the
operators &+ &- & of I.F.ii(a.iv), lowered to the ev_wrap_
int32 overloads spelled out; production Math.ev expands all 8 integer primitives.
METHOD checkedAdd(int32 a, int32 b) RETURNS | int32reads
METHOD hypotenuseLength(float64 x, float64 y) RETURNS float64reads
GEOMETRY