Arithmetic calculations
X +
Y
- Evaluates to the sum of X and Y. If
both operands are integers, the result is an integer; otherwise, the result
is a float. If integer addition results in an overflow, a representation
error is raised.
X -
Y
- Evaluates to the difference of X and Y. If
both operands are integers, the result is an integer; otherwise, the
result is a float. If integer subtraction results in an underflow, a
representation error is raised.
X *
Y
- Evaluates to the product of X and Y.
If both operands are integers, the result is an integer; otherwise, the
result is a float. If integer multiplication results
in an overflow, a representation error is raised.
-
X
- Evaluates to the negative of X. The type of the result,
integer or float, is the same as the type of the operand.
abs(
X)
- Evaluates to
X if X is a positive number, -X if it is a
negative number.
X /
Y
- Evaluates to the quotient of X and Y.
The result is always a float, regardless of the types of the
operands X and Y. Attempt to divide by zero results
in a domain error being raised.
X //
Y
- Evaluates to the integer quotient of X and
Y. X and Y must both be integers. The result is
truncated to the nearest integer that is between it and 0. Attempt to divide
by zero results in a domain error being raised.
X div
Y
- Equivalent to
//
.
X mod
Y
- Evaluates to the remainder after the integer
division of X by Y. X and Y must both be
integers. The result, if non-zero, has the same sign as X. If Y
evaluates to 0, a domain error is raised.
integer(
X)
- Evaluates to X if X is an integer.
Otherwise (if X is a float) the result is the nearest integer that
is between it and 0.
float(
X)
- Evaluates to X if X is a float. Otherwise
(if X is an integer) the result is the floating-point equivalent of X.
min(
X,
Y)
- Evaluates to the minimum of X and Y.
max(
X,
Y)
- Evaluates to the maximum of X and Y.