Math (std::math)
Mathematical helpers.
Usage
The std::math library is available automatically. No import is required.
int r = std::math.randomInt(1, 6);Functions
std::math.randomInt(int a, int b): int
Description: Return a random integer in the inclusive range [a, b].
int r = std::math.randomInt(1, 6);std::math.abs(float x): float
Description: Absolute value.
float y = std::math.abs(-3.2);std::math.clamp(float val, float min, float max): float
Description: Clamp a value to the [min, max] range.
float v = std::math.clamp(10.5, 0.0, 10.0); // 10.0std::math.min(float a, float b): float
float m = std::math.min(2.0, 3.5);std::math.max(float a, float b): float
float m = std::math.max(2.0, 3.5);std::math.round(float x): float
float r = std::math.round(3.6); // 4std::math.floor(float x): float
float r = std::math.floor(3.6); // 3std::math.ceil(float x): float
float r = std::math.ceil(3.1); // 4std::math.sqrt(float x): float
float r = std::math.sqrt(9.0); // 3std::math.pow(float base, float exponent): float
float r = std::math.pow(2.0, 3.0); // 8std::math.PI(): float
Description: The mathematical constant π.
float pi = std::math.PI();