Documentation

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.

For more information on exceptions, see exceptions.

For more information on relaxations, see relaxations.

Mathematics of Fixed Precision

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.

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. 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:

  • Overflow

Relaxations:

  • Binary

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

Arccosine

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
Contact Information

We would be more than happy to help you. Our opening hours are 9–15 (CET).

[email protected]

📞 (+47) 93 68 22 77

Nils Bays vei 50, 0876 Oslo, Norway

Copyright © 2018-24 progsbase.com by Inductive AS.