math
import mathA handful of these are also available directly as number instance methods, without an import: x.abs(), x.floor(), x.ceil(), x.round(), x.sqrt(), x.isNaN(), x.isFinite(), x.isInteger(). See Numbers in the language guide.
Constants
Section titled “Constants”| Constant | Description |
|---|---|
math.pi | π |
math.e | Euler’s number |
math.infinity / math.negInfinity | ±∞ |
math.nan | Not-a-number |
Functions
Section titled “Functions”| Function | Description |
|---|---|
abs(x) | Absolute value |
pow(x, y) / sqrt(x) / cbrt(x) | Power and roots |
sin(x) / cos(x) / tan(x) / asin(x) / acos(x) / atan(x) / atan2(y, x) | Trigonometry |
sinh(x) / cosh(x) / tanh(x) | Hyperbolic trigonometry |
log(x) / log10(x) / log2(x) / exp(x) | Logarithms and exponentiation |
floor(x) / ceil(x) / round(x) / trunc(x) | Rounding |
min(a, b) / max(a, b) / clamp(value, min, max) | Comparison. Preserve int type if both inputs are int |
sign(x) | -1, 0, or 1 |
isNaN(x) / isInfinity(x) / isFinite(x) | Classification |
random() | Random float in [0, 1] |
randomRange(min, max) | Random float in [min, max) |
randomInt(min, max) | Random integer in [min, max) |
radians(degrees) / degrees(radians) | Angular conversion |
lerp(a, b, t) | Linear interpolation |
ilerp(a, b, v) | Inverse linear interpolation — returns t such that lerp(a, b, t) == v |
© 2026 Giraffe Lab LLC. All rights reserved.