Arithmetic & Conversion
Last updated
Sign, magnitude, roots, clamping, primality and character-code conversion.
.abs() → numberAbsolute value.
.invabs() → numberNegative absolute value (always ≤ 0).
.sign() → stringReturns "+" for zero or positive numbers and "-" for negative numbers.
.clamp(min, max) → numberConstrains the value to the range [min, max].
.sqrt() → numberSquare root.
.isPrime() → booleanWhether the (integer) value is prime.
log (-8).sign() // "-"
log (16).sqrt() // 4
log (90).clamp(0, 60) // 60
log (7).isPrime() // true.chr() → stringInterprets the number as a character code and returns the matching character.
Numbers also support the universal conversion methods .toStr(), .toInt(), .toNum(), .toBool(), .getType(), .clone() - see Type & conversion methods.
Last updated
log (65).chr() // "A"