Elementary mathematics as a plugin: every verb is a thin, explicit layer over the C <math.h> functions on double. Integer arguments (i8..i64, u8..u64) are accepted and widened to double; four verbs return an integer (Sign, RoundToInt, IsNaN, IsFinite).
Why a plugin, not operators
The language has no power or root operator on purpose: ^ stays bitwise XOR exactly as in C, and a ** would have no C equivalent — DominScript keeps its "a hot script function converts mechanically to C" promise. Exponentiation is a library call in C; it is a library call here.
Domain errors are errors
A result that is not a finite number is never returned silently. Sqrt(-1), Log(0), Asin(2), Pow(-8, 0.5), Atan2(0, 0) and overflow (Exp(1000)) stop the script with a runtime error naming the offending value — the script asked for a number.
Loading the plugin
plugin "../plugins/print/PrintPlugin"; plugin "../plugins/math/MathPlugin";
A typical flow
double $Dist = math.Hypot($Dx, $Dy);
double $Ang = math.Deg(math.Atan2($Dy, $Dx));
i64 $Px = math.RoundToInt(math.Clamp($X, 0, 1023));
printf("%.2f %.1f %lld\n", $Dist, $Ang, $Px);What to know about every function
Stateless and thread-safe; safe from callback threads.
Angles are radians;
Deg/Radconvert.Roundrounds halves away from zero, like C.
Constants
π and e.
math.Pi
math.Pi() -> double
The constant π (3.14159265358979…).
math.E
math.E() -> double
Euler's number e (2.71828182845904…).
Rounding and sign
Integral values from doubles, and the sign.
math.Abs
math.Abs(x) -> double
Absolute value.
math.Sign
math.Sign(x) -> int
-1, 0 or 1 according to the sign of x.
math.Floor
math.Floor(x) -> double
Largest integral value not greater than x (as a double): Floor(-2.5) is -3.
math.Ceil
math.Ceil(x) -> double
Smallest integral value not less than x: Ceil(-2.5) is -2.
math.Round
math.Round(x) -> double
Nearest integral value, halves rounded away from zero (C round): Round(2.5) is 3, Round(-2.5) is -3.
math.Trunc
math.Trunc(x) -> double
Integral part, toward zero: Trunc(-2.9) is -2.
math.RoundToInt
math.RoundToInt(x) -> int
Like Round but returns an i64; a runtime error when the value does not fit in 64 bits.
Ranges
Minimum, maximum, clamping.
math.Min
math.Min(a, b) -> double
The smaller of two numbers.
math.Max
math.Max(a, b) -> double
The larger of two numbers.
math.Clamp
math.Clamp(x, lo, hi) -> double
x limited to [lo, hi]; a runtime error when lo > hi.
Powers and roots
The functions the language deliberately has no operators for.
math.Pow
math.Pow(x, y) -> double
x raised to the power y. Integers are accepted (Pow(2, 10) is 1024.0). A negative base with a non-integer exponent, a zero base with a negative exponent, or an overflowing result is a runtime error.
math.Sqrt
math.Sqrt(x) -> double
Square root; a negative argument is a runtime error, never a NaN.
math.Cbrt
math.Cbrt(x) -> double
Cube root (defined for negatives: Cbrt(-27) is -3).
math.Hypot
math.Hypot(x, y) -> double
√(x² + y²) without intermediate overflow.
Exponential and logarithms
math.Exp
math.Exp(x) -> double
ex; overflow (Exp(1000)) is a runtime error.
math.Log
math.Log(x) -> double
Natural logarithm; x must be positive.
math.Log2
math.Log2(x) -> double
Base-2 logarithm; x must be positive.
math.Log10
math.Log10(x) -> double
Base-10 logarithm; x must be positive.
Trigonometry
Radians throughout; convert with Deg/Rad.
math.Sin
math.Sin(x) -> double
Sine of x radians.
math.Cos
math.Cos(x) -> double
Cosine of x radians.
math.Tan
math.Tan(x) -> double
Tangent of x radians.
math.Asin
math.Asin(x) -> double
Arc sine, in radians; x must be in [-1, 1].
math.Acos
math.Acos(x) -> double
Arc cosine, in radians; x must be in [-1, 1].
math.Atan
math.Atan(x) -> double
Arc tangent, in radians.
math.Atan2
math.Atan2(y, x) -> double
Angle of the point (x, y) in radians, in (-π, π]; Atan2(0, 0) is a runtime error.
math.Deg
math.Deg(radians) -> double
Radians to degrees.
math.Rad
math.Rad(degrees) -> double
Degrees to radians.
Classification
math.IsNaN
math.IsNaN(x) -> int
1 when x is not a number, else 0.
math.IsFinite
math.IsFinite(x) -> int
1 when x is neither NaN nor infinite, else 0.