Skip to content

Math

The Math namespace contains functions that are available both in the global scope and in the Math namespace.

// Using the Math namespace
x: Math.abs(-10); // sets x to 10
slint
// Using the functions via global scope. No need for 'Math' prefix.
x: abs(-10); // sets x to 10
slint

Some of the math functions can be used in a postfix style which can make the code more readable.

// Using the postfix style.
x: (-10).abs(); // sets x to 10
slint

T type Many of the math functions can be used with any numeric type such as angle, duration, float, int, length, and percent. These are represented on this page as T.

Return the absolute value, where T is a numeric type.

Math.abs(-10); // returns 10
abs(-10px); // returns 10px
(-10).abs(); // returns 10
slint

Returns the value rounded up to the nearest integer.

Math.ceil(4); // returns 4
Math.ceil(2.3); // returns 3
Math.ceil(-1.5); // returns -1
slint

Returns the value rounded down to the nearest integer.

Math.floor(4); // returns 4
Math.floor(2.3); // returns 2
Math.floor(-1.5); // returns -2
slint

Return the value rounded to the nearest integer

Math.round(4.5); // returns 5
Math.round(4.4); // returns 4
Math.round(-1.2); // returns -1
slint

Takes a value, minimum and maximum and returns maximum if value > maximum, minimum if value < minimum, or value in all other cases.

Return the log of the first value with a base of the second value

Return the arguments with the minimum (or maximum) value. All arguments must be of the same numeric type.

Math.min(1, 2); // returns 1
Math.min(2, 1); // returns 1
Math.max(1, 2); // returns 2
Math.max(2, 1); // returns 2
slint

Perform a modulo operation, where T is some numeric type. Returns the remainder of the euclidean division of the arguments. This always returns a positive number between 0 and the absolute value of the second value.

Square root

Return the value of the first value raised to the second

Returns the arccosine, or inverse cosine, of a number. The arccosine is the angle whose cosine is number.

Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is number.

Returns the arctangent, or inverse tangent, of a number.

The trigonometry function. Note that the should be typed with deg or rad unit (for example cos(90deg) or sin(slider.value * 1deg)).


© 2025 SixtyFPS GmbH