| Search internet |
The usual arithmetic operations of addition, subtraction, and multiplication are as follows:
""D 8 + x - x ""D 10 x * y ""D 12 x + y x - y
The ""D lines indicate the charges of the operators. So addition and subtraction has greatest charge, then comes multiplication, and then comes unary plus and minus. The charges are even so the constructs are pre-associative. As an example,

means

and

means

Division operations have charge 16:
""D 16 x div y x mod y
As an example,

means

If x and y are integers and if y is positive, then
and
denote the unique integers which satisfy the following:


When y is zero or negative,
and
return
.
Note in particular that
and
do not allow to divide by negative numbers (or, rather, throw an exception if someone tries to divide by a negative number). That is because there is no definition of division by negative numbers (or, rather, there are two possible ones which are equally good). The base page implements the most conservative solution to that which is to stick to the definition above which requires

That condition cannot be satisfied when y is zero or negative. Anyone who wants to divide by negative numbers can define their own
and
operations according to their preferences.
The
operation computes both
and
and return them as a pair:

The base page defines a total of four division operations which return a pair of a quotient and a remainder:
floor ( x , y ) ceiling ( x , y ) truncate ( x , y ) round ( x , y )
They all satisfy similar equations:




The difference is in the rounding direction. The floor, ceiling, truncate, and round operations round in the direction of minus infinity, plus infinity, zero, and nearest integer, respectively. For the latter, if two integers are equally near to the exact result, the even of the two is chosen. These four kinds of rounding correspond to the four rounding modes of the IEEE floating point standard.
| Search logiweb.eu |