Documentation

Binary Arithmetic Operators

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

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

Addition

Syntax: x = a + b

Description: Sets x to the sum of a and b.

Exceptions:

  • Overflow

Relaxations:

  • Binary
  • Exception

Subtraction

Syntax: x = a - b

Description: Sets x to the difference between a and b.

Exceptions:

  • Overflow

Relaxations:

  • Binary
  • Exception

Multiplication

Syntax: x = a * b

Description: Sets x to the product of a and b.

Exceptions:

  • Overflow

Relaxations:

  • Binary
  • Exception

Division

Syntax: x = a / b

Description: Sets x to a divided by b.

Exceptions:

  • Overflow
  • Invalid operand, if b is zero.

Relaxations:

  • Binary
  • Exception

Exponentiation

Syntax: x = a ^ b

Description: Sets x to a to the power of b.

Exceptions:

  • Overflow
  • Invalid operand
    • If both a and b are zero.
    • If a is negative and b is not a whole number.

Relaxations:

  • Binary
  • Exception

Modulus

Syntax: x = a mod b

Description: Sets x to the reminder of a divided by b with integer division. The result is 0 <= x < b. Another way at looking at it is that x = a - q*b, where q is the integer quotient when a is divided by b using integer division.

Exceptions:

  • Invalid operand
    • If a is negative.
    • If b is zero.
    • If b is negative.

Relaxations:

  • Binary
  • Exception

Max

Syntax: x = max(a, b)

Description: x is set to the larger of a and b.

Min

Syntax: x = min(a, b)

Description: x is set to the smaller of a and b.

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.