Math
Math builtins in Tish.
Constants
| Constant | Value |
|---|---|
Math.PI | π |
Math.E | e (Euler's number) |
Unary
| Method | Description |
|---|---|
Math.abs(x) | Absolute value |
Math.sqrt(x) | Square root |
Math.floor(x) | Floor |
Math.ceil(x) | Ceiling |
Math.round(x) | Round |
Math.trunc(x) | Truncate |
Math.sign(x) | Sign (-1, 0, or 1) |
Math.sin(x) | Sine (radians) |
Math.cos(x) | Cosine (radians) |
Math.tan(x) | Tangent (radians) |
Math.asin(x) | Arc sine |
Math.acos(x) | Arc cosine |
Math.atan(x) | Arc tangent |
Math.log(x) | Natural log |
Math.log10(x) | Log base 10 |
Math.log2(x) | Log base 2 |
Math.exp(x) | e^x |
Math.cbrt(x) | Cube root |
Binary / variadic
| Method | Description |
|---|---|
Math.min(a, b, ...) | Minimum |
Math.max(a, b, ...) | Maximum |
Math.pow(base, exp) | Exponentiation |
Math.atan2(y, x) | Arc tangent of y/x |
Math.hypot(x, y) | √(x² + y²) |
Random
| Method | Description |
|---|---|
Math.random() | Random number in [0, 1) |