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.
For more information on exceptions, see exceptions.
For more information on relaxations, see relaxations.
All operations result in a decimal number type with 15 digits. The mathematics of this is covered in the section on the Decimal Number Type.
Syntax: x = -a
Description: Sets x to the negation of a.
Syntax: x = +a
Description: Sets x to the positive of a.
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)
.
Syntax: x = ceil(a)
Description: Sets x to the integer closest to a upwards.
Syntax: x = floor(a)
Description: Sets x to the integer closes to a downwards.
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.
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.
Syntax: x = log(a)
Description: Sets x to the logarithm base 10 of a.
Exceptions:
Relaxations:
Syntax: x = ln(x)
Description: Sets x to the logarithm base e of a, also known as the natural logarithm.
Exceptions:
Relaxations:
Syntax: x = sin(a)
Description: Sets x to the sine of a. This is the radians version of sine.
Relaxations:
Syntax: x = cos(x)
Description: Sets x to the cosine of a. This is the radians version of cosine.
Relaxations:
Syntax: x = tan(a)
Description: Sets x to the tangent of a. This is the radians version of tangent. Tangent cannot be performed on pi/2 + n*pi
for any integer n. Values of a approaching these values will cause an overflow exception.
Exceptions:
Relaxations:
Syntax: x = asin(a)
Description: Sets x to the arcsine of a. The result is in radians.
Exceptions:
Relaxations:
Syntax: x = acos(a)
Description: Sets x to the arccosine of a. The result is in radians.
Exceptions:
Relaxations:
Syntax: x = atan(a)
Description: Sets x to the arctangent of a. The result is in radians.
Relaxations:
Syntax: x = sqrt(a)
Description: Sets x to the square root of a.
Exceptions:
Relaxations:
Syntax: x = exp(a)
Description: Sets x to e to the power of x, e^x
, where e
is the constant e.
Exceptions:
Relaxations:
We would be more than happy to help you. Our opening hours are 9–15 (CET).
📞 (+47) 93 68 22 77
Nils Bays vei 50, 0876 Oslo, Norway