# Math Functions

Functions for performing various mathematical operations such as rounding, exponentiation, squaring, etc.

• General Math:
• Abs: Returns the absolute value of a number.
• Ceil: Returns a number rounded up to the nearest integer.
• Exp: Returns e raised to the Nth power.
• Floor: Returns a number rounded down to the nearest integer.
• Log: Returns the logarithm (base 10) of a number.
• Ln: Returns the natural logarithm (base e) of a number.
• Max: Returns the highest value of one or more numbers.
• Min: Returns the lowest value of one or more numbers.
• Mod: Returns the remainder of a division.
• Round: Returns a number rounded to N decimal places.
• Sqrt: Returns the square root of a number.
• Trigonometry:
• Sin: Returns the trigonometric sine of a number.
• Cos: Returns the trigonometric cosine of a number.
• Tan: Returns the trigonometric tangent of a number.
• ASin: Returns the arcsine (the number whose sine is the specified number) in radians.
• ACos: Returns the arccosine (the number whose cosine is the specified number) in radians.
• ATan: Returns the arctangent (the number whose tangent is the specified number) in radians.
• Error-handling

## General Math

### Abs

Returns the absolute value of the specified number.

`Value := Abs(Number)`

The return value is the same type as Number (integer or floating point).

`MsgBox Abs(-1.2) ; Returns 1.2`

### Ceil

Returns the specified number rounded up to the nearest integer (without any .00 suffix).

`Value := Ceil(Number)`
```MsgBox Ceil(1.2)  ; Returns 2
MsgBox Ceil(-1.2) ; Returns -1```

### Exp

Returns e (which is approximately 2.71828182845905) raised to the Nth power.

`Value := Exp(N)`

N may be negative and may contain a decimal point. To raise numbers other than e to a power, use the ** operator.

`MsgBox Exp(1.2) ; Returns 3.320117`

### Floor

Returns the specified number rounded down to the nearest integer (without any .00 suffix).

`Value := Floor(Number)`
```MsgBox Floor(1.2)  ; Returns 1
MsgBox Floor(-1.2) ; Returns -2```

### Log

Returns the logarithm (base 10) of the specified number.

`Value := Log(Number)`

The result is a floating-point number. If Number is negative, a ValueError is thrown.

`MsgBox Log(1.2) ; Returns 0.079181`

### Ln

Returns the natural logarithm (base e) of the specified number.

`Value := Ln(Number)`

The result is a floating-point number. If Number is negative, a ValueError is thrown.

`MsgBox Ln(1.2) ; Returns 0.182322`

### Max

Returns the highest value of one or more numbers.

`Value := Max(Number1 , Number2, ...)`
`MsgBox Max(2.11, -2, 0) ; Returns 2.11`

You can also specify a variadic parameter to compare multiple values within an array. For example:

```Numbers := [1, 2, 3, 4]
MsgBox Max(Numbers*) ; Returns 4
```

### Min

Returns the lowest value of one or more numbers.

`Value := Min(Number1 , Number2, ...)`
`MsgBox Min(2.11, -2, 0) ; Returns -2`

You can also specify a variadic parameter to compare multiple values within an array. For example:

```Numbers := [1, 2, 3, 4]
MsgBox Min(Numbers*) ; Returns 1```

### Mod

Modulo. Returns the remainder of the specified dividend divided by the specified divisor.

`Value := Mod(Dividend, Divisor)`

The sign of the result is always the same as the sign of the first parameter. If either input is a floating point number, the result is also a floating point number. If the second parameter is zero, a ZeroDivisionError is thrown.

`MsgBox Mod(7.5, 2) ; Returns 1.5 (2 x 3 + 1.5)`

### Round

Returns the specified number rounded to N decimal places.

`Value := Round(Number , N)`

If N is omitted or 0, Number is rounded to the nearest integer:

`MsgBox Round(3.14)    ; Returns 3`

If N is positive number, Number is rounded to N decimal places:

`MsgBox Round(3.14, 1) ; Returns 3.1`

If N is negative, Number is rounded by N digits to the left of the decimal point:

```MsgBox Round(345, -1) ; Returns 350
MsgBox Round(345, -2) ; Returns 300```

The result is an integer if N is omitted or less than 1. Otherwise, the result is a numeric string with exactly N decimal places. If a pure number is needed, simply perform another math operation on Round's return value; for example: `Round(3.333, 1)+0`.

### Sqrt

Returns the square root of the specified number.

`Value := Sqrt(Number)`

The result is a floating-point number. If Number is negative, a ValueError is thrown.

`MsgBox Sqrt(16) ; Returns 4`

## Trigonometry

Note: To convert a radians value to degrees, multiply it by 180/pi (approximately 57.29578). To convert a degrees value to radians, multiply it by pi/180 (approximately 0.01745329252). The value of pi (approximately 3.141592653589793) is 4 times the arctangent of 1.

### Sin

Returns the trigonometric sine of the specified number.

`Value := Sin(Number)`

Number must be expressed in radians.

`MsgBox Sin(1.2) ; Returns 0.932039`

### Cos

Returns the trigonometric cosine of the specified number.

`Value := Cos(Number)`

Number must be expressed in radians.

`MsgBox Cos(1.2) ; Returns 0.362358`

### Tan

Returns the trigonometric tangent of the specified number.

`Value := Tan(Number)`

Number must be expressed in radians.

`MsgBox Tan(1.2) ; Returns 2.572152`

### ASin

Returns the arcsine (the number whose sine is the specified number) in radians.

`Value := ASin(Number)`

If Number is less than -1 or greater than 1, a ValueError is thrown.

`MsgBox ASin(0.2) ; Returns 0.201358`

### ACos

Returns the arccosine (the number whose cosine is the specified number) in radians.

`Value := ACos(Number)`

If Number is less than -1 or greater than 1, a ValueError is thrown.

`MsgBox ACos(0.2) ; Returns 1.369438`

### ATan

Returns the arctangent (the number whose tangent is the specified number) in radians.

`Value := ATan(Number)`
`MsgBox ATan(1.2) ; Returns 0.876058`

## Error-Handling

These functions throw an exception if any incoming parameters are non-numeric or an invalid operation (such as divide by zero) is attempted.