Skip to content

Math

The @std/math module provides common numeric helpers.

import math from "@std/math"
println(math.sqrt(16))
NameReturnsDescription
abs(number)numberAbsolute value.
sqrt(number)floatSquare root.
pow(base, exp)floatRaises base to exp.
sin(x)floatSine of x.
cos(x)floatCosine of x.

Returns the absolute value of an integer or float.

import math from "@std/math"
println(math.abs(-10))
println(math.abs(-3.5))

Returns the square root as a float.

import math from "@std/math"
let value = math.sqrt(81)
println(value)

Raises a number to a power.

import math from "@std/math"
println(math.pow(2, 8))

Returns the sine of a number.

import math from "@std/math"
println(math.sin(0))

Returns the cosine of a number.

import math from "@std/math"
println(math.cos(0))