Skip to content
You're reading the docs for Railroader 0.6 (the MoW Update), currently available on the Experimental branch.

math

import math

A 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.

ConstantDescription
math.piπ
math.eEuler’s number
math.infinity / math.negInfinity±∞
math.nanNot-a-number
FunctionDescription
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