Math
Static methods on the Math module.
Methods
| Method | Returns | Description |
|---|---|---|
Math.abs(x) | int | Absolute value |
Math.max(a, b) | int | Maximum |
Math.min(a, b) | int | Minimum |
Math.pow(base, exp) | int | Power |
Math.sqrt(x) | float | Square root |
Math.clamp(x, lo, hi) | int | Clamp to range |
Math.sign(x) | int | -1, 0, or 1 |
Math.lerp(a, b, t) | float | Linear interpolation |
Math.map_range(x, a1, a2, b1, b2) | float | Map between ranges |
Math.log(x) | float | Natural log |
Math.log10(x) | float | Base-10 log |
Math.exp(x) | float | e^x |
Math.random() | int | Random integer |
Examples
wyn
println(Math.abs(-5).to_string()) // 5
println(Math.max(10, 20).to_string()) // 20
println(Math.pow(2, 8).to_string()) // 256
println(Math.sqrt(16).to_string()) // 4.0
println(Math.clamp(150, 0, 100).to_string()) // 100