std.math
pi binding
pub let pi: float = 3.141592653589793
stdlib/std/math.lyr:13
e binding
pub let e: float = 2.718281828459045
stdlib/std/math.lyr:14
sqrt function
pub fn sqrt(value: float): float
stdlib/std/math.lyr:16
abs function
pub fn abs(value: float): float
stdlib/std/math.lyr:17
floor function
pub fn floor(value: float): float
stdlib/std/math.lyr:21
ceil function
pub fn ceil(value: float): float
stdlib/std/math.lyr:22
round function
pub fn round(value: float): float
stdlib/std/math.lyr:23
min function
pub fn min(a: float, b: float): float
stdlib/std/math.lyr:25
max function
pub fn max(a: float, b: float): float
stdlib/std/math.lyr:26
pow function
pub fn pow(base: float, exponent: float): float
stdlib/std/math.lyr:27
sin function
pub fn sin(radians: float): float
stdlib/std/math.lyr:29
cos function
pub fn cos(radians: float): float
stdlib/std/math.lyr:30
tan function
pub fn tan(radians: float): float
stdlib/std/math.lyr:31
log function
pub fn log(value: float): float
stdlib/std/math.lyr:34
asin function
pub fn asin(value: float): float
stdlib/std/math.lyr:42
acos function
pub fn acos(value: float): float
stdlib/std/math.lyr:43
atan function
pub fn atan(value: float): float
stdlib/std/math.lyr:44
atan2 function
pub fn atan2(y: float, x: float): float
stdlib/std/math.lyr:45
tau binding
pub let tau: float = 6.283185307179586
stdlib/std/math.lyr:49
absInt function
pub fn absInt(value: int): int
stdlib/std/math.lyr:56
minInt function
pub fn minInt(a: int, b: int): int
stdlib/std/math.lyr:60
maxInt function
pub fn maxInt(a: int, b: int): int
stdlib/std/math.lyr:64
clampInt function
pub fn clampInt(value: int, lo: int, hi: int): int
Clamps to [lo, hi]. A lo > hi yields lo; the bounds are the caller's business.
stdlib/std/math.lyr:69
signInt function
pub fn signInt(value: int): int
stdlib/std/math.lyr:76
gcd function
pub fn gcd(a: int, b: int): int
Greatest common divisor, Euclidean. Always non-negative.
stdlib/std/math.lyr:84
lcm function
pub fn lcm(a: int, b: int): int
Least common multiple. lcm(0, n) is 0.
stdlib/std/math.lyr:96
powInt function
pub fn powInt(base: int, exponent: int): ?int
Integer power by repeated squaring.
A negative exponent yields null: the result would be a fraction.
stdlib/std/math.lyr:108
divFloor function
pub fn divFloor(a: int, b: int): int
Division rounding towards negative infinity rather than towards zero.
/ and % follow the sign of the dividend, so -7 / 2 is -3.
Computing on a grid (tiles, time windows) needs -4. Both forms stand side by side so the
choice is visible.
stdlib/std/math.lyr:131
modFloor function
pub fn modFloor(a: int, b: int): int
The remainder matching divFloor, always carrying the sign of b.
stdlib/std/math.lyr:141
clamp function
pub fn clamp(value: float, lo: float, hi: float): float
stdlib/std/math.lyr:151
sign function
pub fn sign(value: float): float
stdlib/std/math.lyr:158
trunc function
pub fn trunc(value: float): float
Truncates towards zero: trunc(-2.7) is -2.0, while floor(-2.7) would be -3.0.
stdlib/std/math.lyr:166
isNaN function
pub fn isNaN(value: float): bool
NaN is the only value unequal to itself (IEEE 754), so this needs no native edge and no bit
access.
stdlib/std/math.lyr:172
isInfinite function
pub fn isInfinite(value: float): bool
stdlib/std/math.lyr:176
isFinite function
pub fn isFinite(value: float): bool
stdlib/std/math.lyr:184
exp function
pub fn exp(value: float): float
stdlib/std/math.lyr:188
log2 function
pub fn log2(value: float): float
stdlib/std/math.lyr:194
log10 function
pub fn log10(value: float): float
stdlib/std/math.lyr:195
logBase function
pub fn logBase(value: float, base: float): float
Logarithmus zu beliebiger Basis.
stdlib/std/math.lyr:198
cbrt function
pub fn cbrt(value: float): float
The cube root, negative values included.
pow(x, 1/3) alone yields NaN for negative x: a fractional power is undefined there. The
cube root is not, and the sign simply moves out.
stdlib/std/math.lyr:206
hypot function
pub fn hypot(a: float, b: float): float
The length of the hypotenuse.
stdlib/std/math.lyr:214
sinh function
pub fn sinh(value: float): float
stdlib/std/math.lyr:218
cosh function
pub fn cosh(value: float): float
stdlib/std/math.lyr:222
tanh function
pub fn tanh(value: float): float
stdlib/std/math.lyr:226
toRadians function
pub fn toRadians(degrees: float): float
stdlib/std/math.lyr:230
toDegrees function
pub fn toDegrees(radians: float): float
stdlib/std/math.lyr:234
Random class
pub class Random
state: int
pub mut fn nextInt(): int
The next raw value. It may have either sign.
pub mut fn nextIntRange(lo: int, hi: int): int
Uniformly distributed in [lo, hi). An empty range yields lo.
pub mut fn nextFloat(): float
Uniformly distributed in [0, 1).
pub mut fn nextBool(): bool
stdlib/std/math.lyr:250
newRandom function
pub fn newRandom(seed: int): Random
A generator with an explicit seed.
A seed of 0 is a fixed point for xorshift — the sequence would stay 0 forever — so it is replaced silently rather than panicking on a plausible input.
stdlib/std/math.lyr:288