# Standard Library: Math functions

## abs


[%abs: num]



int | float

Prints the absolute value of num.

### Parameters

numint | float
The input number.

### Errors

Raises an error if num is an integer and the absolute value overflows.





any

Adds two values and prints the sum.

### Parameters

lhsany
The left-hand operand of the addition.

rhsany
The right-hand operand of the addition.

## ceil


[%ceil: val]



int

Prints the smallest integer that is greater than or equal to val.

### Parameters

valfloat
The input number.

## div


[%div: lhs; rhs]



any

Divides two values and prints the quotient.

### Parameters

lhsany
The left-hand operand (dividend).

rhsany
The right-hand operand (divisor).

## floor


[%floor: val]



int

Prints the largest integer that is less than or equal to val.

### Parameters

valfloat
The input number.

## frac


[%frac: val]



float

Prints the fractional part of val.

### Parameters

valfloat
The input number.

## max


[%max: values+]



any

Returns the largest value in values.

Any elements of type list in values will be expanded to their individual elements before the maximum value is calculated.

### Parameters

valuesany+
The input values.

### Examples

# Arguments can be single values
[max: 3; 2 |> assert-eq: 3]

# Lists are treated as their individual elements
[max: (3; 2) |> assert-eq: 3]

# Even alongside single values, lists are still expanded!
[max: 3; (4; -2; 0; 10); 6 |> assert-eq: 10]


## min


[%min: values+]



any

Returns the smallest value in values.

Any elements of type list in values will be expanded to their individual elements before the minimum value is calculated.

### Parameters

valuesany+
The input values.

### Examples

# Arguments can be single values
[min: 3; 2 |> assert-eq: 2]

# Lists are treated as their individual elements
[min: (3; 2) |> assert-eq: 2]

# Even alongside single values, lists are still expanded!
[min: 3; (4; -2; 0; 10); 6 |> assert-eq: -2]


## mod


[%mod: lhs; rhs]



any

Gets the modulus of two values.

### Parameters

lhsany
The left-hand operand (dividend).

rhsany
The right-hand operand (divisor).

## mul


[%mul: lhs; rhs]



any

Multiplies two values and prints the product.

### Parameters

lhsany
The left-hand operand.

rhsany <br.> The right-hand operand.





any

Multiplies two values, then adds another value to the result.

### Parameters

lhsany
The left-hand operand of the multiplication.

rhsany
The right-hand operand of the multiplication.

addany
The value to add to the product.

## neg


[%neg: val]



any

Negates a value and prints it.

### Parameters

valany
The input value.

## recip


[%recip: n]



any

Gets the reciprocal of a value.

## sub


[%sub: lhs; rhs]



any

Prints the difference between two values.

### Parameters

lhsany
The left-hand operand of the subtraction.

rhsany
The right-hand side of the subtraction.

## sin


[%sin: x]



float

Calculates the sine of x.

### Parameters

xfloat

## cos


[%cos: x]



float

Calculates the cosine of x.

### Parameters

xfloat

## tan


[%tan: x]



float

Calculates the tangent of x.

### Parameters

xfloat

## asin


[%asin: x]



float

Calculates the arcsine (in radians) of x.

### Parameters

xfloat
The input sine value.

## acos


[%acos: x]



float

Calculates the arccosine (in radians) of x.

### Parameters

xfloat
The input cosine value.

## atan


[%atan: x]



float

Calculates the arctangent (in radians) of x.

### Parameters

xfloat
The input tangent value.

## atan2


[%atan2: y; x]



float

Calculates the four-quadrant arctangent (in radians) of $$\frac{y}{x}$$.

Returns 0 if x or y is 0.

### Parameters

yfloat
The input tangent's numerator.

xfloat
The input tangent's denominator.

## sqrt


[%sqrt: x]



float

Calculates the square root of x.

### Parameters

xint | float
The input value.

## pow


[%pow: x; y]



int | float

Calculates $$x^y$$ and prints the result. Both x and y can be int or float.

### Parameters

xint | float
The base number.

yint | flaot
The exponent to raise x to.

### Errors

Raises an overflow error if a x is an int and x ^ y causes an overflow.