envzn
0.8 · beta · not released

Library / Numbers / Math / Math

CLASS

Math

NAMESPACE of standard math functions and constants.

Fields 7

float64 PI
float64 TAU
float64 E
float64 PHI
float64 EM
float64 SQRT2
float64 LN2

Methods 40

METHOD abs(int32 x) RETURNS int32
reads

ABSOLUTE VALUE — overloads per primitive

METHOD abs(float64 x) RETURNS float64
reads
METHOD isNaN(float64 x) RETURNS boolean
reads

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 boolean
reads
METHOD isFinite(float64 x) RETURNS boolean
reads

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 boolean
reads
METHOD squareRoot(float64 x) RETURNS complex
reads

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 float64
reads
METHOD exponent(float64 base, float64 exp) RETURNS | float64
reads
METHOD eulersExponent(float64 x) RETURNS float64
reads
METHOD loge(float64 x) RETURNS | float64
reads

LOGARITHMS — x must be > 0; FAILURE STATUS otherwise.

METHOD log2(float64 x) RETURNS | float64
reads
METHOD log10(float64 x) RETURNS | float64
reads
METHOD sin(float64 x) RETURNS float64
reads

TRIGONOMETRY — radians; asin/acos domain-checked.

METHOD cos(float64 x) RETURNS float64
reads
METHOD tan(float64 x) RETURNS float64
reads
METHOD asin(float64 x) RETURNS | float64
reads
METHOD acos(float64 x) RETURNS | float64
reads
METHOD atan(float64 x) RETURNS float64
reads
METHOD atan2(float64 y, float64 x) RETURNS float64
reads
METHOD sinh(float64 x) RETURNS float64
reads
METHOD cosh(float64 x) RETURNS float64
reads
METHOD tanh(float64 x) RETURNS float64
reads
METHOD floor(float64 x) RETURNS float64
reads

ROUNDING — float64 in, float64 out

METHOD ceiling(float64 x) RETURNS float64
reads
METHOD round(float64 x) RETURNS float64
reads
METHOD truncate(float64 x) RETURNS float64
reads
METHOD sign(int32 x) RETURNS int32
reads

SIGN — returns -1, 0, or 1 as int32 regardless of input type

METHOD sign(float64 x) RETURNS int32
reads
METHOD min(int32 a, int32 b) RETURNS int32
reads

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 float64
reads
METHOD max(int32 a, int32 b) RETURNS int32
reads
METHOD max(float64 a, float64 b) RETURNS float64
reads
METHOD clamp(int32 v, int32 lo, int32 hi) RETURNS int32
reads
METHOD clamp(float64 v, float64 lo, float64 hi) RETURNS float64
reads
METHOD toRadians(float64 deg) RETURNS float64
reads

ANGLE CONVERSION

METHOD toDegrees(float64 rad) RETURNS float64
reads
METHOD saturatingAdd(int32 a, int32 b) RETURNS int32
reads

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_ intrinsics — not a method): - saturatingAdd: clamps at the type's min/max - checkedAdd: returns (value, STATUS); FAILURE on overflow

int32 overloads spelled out; production Math.ev expands all 8 integer primitives.

METHOD checkedAdd(int32 a, int32 b) RETURNS | int32
reads
METHOD hypotenuseLength(float64 x, float64 y) RETURNS float64
reads

GEOMETRY