# Unary Arithmetic Operators

The following is the documentation for unary arithmetic operators. The unary arithmetic operators are of the form: `x = <operator> a` or `x = <operator name>(a)`.

The documentation includes references to exceptions and relaxations.

## Rounding

All operations result in a decimal number type with 15 digit precision. The result is rounded correctly to fit this precision.

## Operators

### Negation

Syntax: `x = -a`

Description: Sets x to the negation of a.

### Positive

Syntax: `x = +a`

Description: Sets x to the positive of a.

### Round

Alltough most languages have a round function, it is implemented differently. The two main problems are 1) rounding with negative numbers and 2) rounding of exactly half-way numbers.

Round is defined properly as `floor(x + 0.5)`.

### Ceil

Syntax: `x = ceil(a)`

Description: Sets x to the integer closest to a upwards.

### Floor

Syntax: `x = floor(a)`

Description: Sets x to the integer closes to a downwards.

### Truncate

Syntax: `x = truncate(a)`

Description: Sets x to the integer closest to a towards zero. In other words, the part after the decimal point is cut off.

### Absolute

Syntax: `x = |a|` or `x = abs(a)`.

Description: Sets x to the absolute value of a, which means if a is negative, a is negated.

### Logarithm

Syntax: `x = log(a)`

Description: Sets x to the logarithm base 10 of a.

Exceptions:

• Invalid operand, if a is 0 or less.

Relaxations:

• Binary
• Exception

### Natural Logarithm

Syntax: `x = ln(x)`

Description: Sets x to the logarithm base e of a, also known as the natural logarithm.

Exceptions:

• Invalid operand, if a is 0 or less.

Relaxations:

• Binary
• Exception

### Sine

Syntax: `x = sin(a)`

Description: Sets x to the sine of a. This is the radians version of sine.

Relaxations:

• Binary

### Cosine

Syntax: `x = cos(x)`

Description: Sets x to the cosine of a. This is the radians version of cosine.

Relaxations:

• Binary

### Tangent

Syntax: `x = tan(a)`

Description: Sets x to the tangent of a. This is the radians version of tangent.

Exceptions:

• Overflow
• Invalid operand, if a is equal to `i*pi/2`, for any integer value `i`. Where pi is the constant pi.

Relaxations:

• Binary
• Exception

### Arcsine

Syntax: `x = asin(a)`

Description: Sets x to the arcsine of a. The result is in radians.

Exceptions:

• Invalid operands
• if a is less than -1
• if a is more than 1

Relaxations:

• binary
• exception

### Arccos

Syntax: `x = acos(a)`

Description: Sets x to the arccosine of a. The result is in radians.

Exceptions:

• Invalid operands
• if a is less than -1
• if a is more than 1

Relaxations:

• binary
• exception

### Arctangent

Syntax: `x = atan(a)`

Description: Sets x to the arctangent of a. The result is in radians.

Relaxations:

• binary

### Square Root

Syntax: `x = sqrt(a)`

Description: Sets x to the square root of a.

Exceptions:

• Invalid operand, if a is less than zero.

Relaxations:

• binary
• exception

### Exponential

Syntax: `x = exp(a)`

Description: Sets x to e to the power of x, `e^x`, where `e` is the constant e.

Exceptions:

• Overflow

Relaxations:

• Exception
• Binary