Math functions
Arithmetic, rounding, roots, logs, and trigonometry.
| Function | Description |
|---|---|
| abs(x: f64) → f64 | Absolute value. |
| acos(x: number) → f64 | Arccosine, in radians, of a value in [-1, 1]. |
| asin(x: number) → f64 | Arcsine, in radians, of a value in [-1, 1]. |
| atan(x: number) → f64 | Arctangent, in radians. |
| atan2(a: number, b: number) → f64 | Arctangent of a/b in radians, using the signs of both to pick the quadrant. |
| cbrt(x: f64) → f64 | Cube root. |
| ceil(x: f64) → f64 | Round up to the nearest integer. |
| clamp(x: number, lo: number, hi: number) → f64 | Constrain x to the range [lo, hi]. |
| cos(x: f64) → f64 | Cosine of an angle in radians. |
| degrees(x: number) → f64 | Convert an angle from radians to degrees. |
| e() → f64 | Euler's number e (≈ 2.71828). |
| exp(x: f64) → f64 | e raised to the power x. |
| floor(x: f64) → f64 | Round down to the nearest integer. |
| hypot(a: f64, b: f64) → f64 | Length of the hypotenuse sqrt(a² + b²). |
| ln(x: f64) → f64 | Natural (base-e) logarithm. |
| log10(x: f64) → f64 | Base-10 logarithm. |
| log2(x: f64) → f64 | Base-2 logarithm. |
| max(a: f64, b: f64) → f64 | The larger of two numbers. |
| min(a: f64, b: f64) → f64 | The smaller of two numbers. |
| pi() → f64 | The constant π (≈ 3.14159). |
| pow(a: f64, b: f64) → f64 | Raise a to the power b. |
| radians(x: number) → f64 | Convert an angle from degrees to radians. |
| round(x: f64) → f64 | Round to the nearest integer (ties away from zero). |
| sign(x: f64) → f64 | The sign of x: 1, -1, or 0. |
| sin(x: f64) → f64 | Sine of an angle in radians. |
| sqrt(x: f64) → f64 | Square root. |
| tan(x: f64) → f64 | Tangent of an angle in radians. |
| tau() → f64 | The constant τ = 2π (≈ 6.28319). |
| trunc(x: f64) → f64 | Discard the fractional part, rounding toward zero. |