lib/newMath.spl)
Pure SPL math helpers: constants pi and
e, plus functions registered as
function.power,
function.abs, and others. Load with
use newMath; (extensionless import is allowed because the file starts with
reqFileExtension.setVar(false);).
use newMath; print.number(pi); print.number(function.power(2, 8));
pi — double-precision π.e — Euler’s number.function.power(a, b) — a to the integer power b (repeated multiply).function.abs(a) — absolute value.function.isPrime(a) — trial division up to floor(sqrt(a)).function.gcd(a, b) — Euclidean GCD (recursive).function.factorial(n) — non-negative integers only; invalid input uses return.boolean(null).function.lcm(a, b) — via a*b/gcd(a,b).function.isInteger(a) — true when type.isNumber and value equals math.floor(a).
Implementation: someProgrammingLanguage/lib/newMath.spl