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.

Rounding

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

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 the larger of a and b.

Min

Syntax: x = min(a, b)

Description: x is the smaller of a and b,