HI ALEX

The Integer Divide (DIV) OperatorThe integer divide operator is used only as a binary operator. Its purpose is to

divide the numeric term preceding it by the numeric term following it. The result

type of this division is always of type Integer. If the second term is zero (0), a

run-time error occurs. Any decimals that resulted from an ordinary division are

dropped. Therefore, the result of 17 DIV 8 is 2, whereas the result of 17 DIV 9 is

1.

The Modulus (MOD) OperatorThe modulus operator (or the remainder operator) is used only as a binary

operator. Its purpose is to divide the numeric term preceding it by the numeric

term following it by using the integer division method and then return the

remainder of that division. The result of this operation is always of type Integer.

If the second term is zero (0), a run-time error occurs. The following shows

examples of modulus operator usage.

• 17 MOD 8 = 1

• 17 MOD 9 = 8

The modulus operator requires two numbers. The first number is the one that is

converted by using the modulus function and the second number represents the

number system being used. By definition the number system starts at zero and

ends at the second number minus one. For example, if the second number is ten,

the number system that is used is from zero to nine. Therefore, the modulus

represents what the first number converts to, if the numbering system only had

the number of values indicated by the second number and the first number is

forced to restart from zero.

The following example shows several modulus operations:

• 15 modulus 10 is 5 (because 9 is the last number available, 10 is

represented by going back from the start, or zero, 11 is 1, 12 is 2, and

so on)

• 6 modulus 10 is 6

• 10 modulus 10 is 0

• 127 modulus 10 is 7

The result is the same if the first number is divided by the second by using an

integer only and the remainder is returned as the value.