Chapter 5: Using Operators and Expressions in Access
175
The integer division operator: \
The integer division operator takes any two numbers (number1 and number2), rounds them up
or down to integers, divides the first by the second (number1 / number2), and then drops the
decimal portion, leaving only the integer value. Here are some examples of how integer division
differs from normal division:
Normal Division Integer Conversion Division
100 / 6 = 16.667 100 \ 6 = 16
100.9 / 6.6 = 15.288 100.9 \ 6.6 = 14
102 / 7 = 14.571 102 \ 7 = 14
Note
Access rounds whole numbers based on a principle known as “banker’s rounding” or “round half to even.”
Rounding is always done to the nearest even number: 6.5 becomes 6, and 7.5 becomes 8. This is only an issue,
of course, when the rounded value is exactly midway between two whole numbers. 6.51 rounds (as you’d
expect) to 7, and 6.49 rounds to 6.
The exponentiation operator: ^
The exponentiation operator (^) raises a number to the power of an exponent. Raising a number
simply means multiplying a number by itself. For example, multiplying the value 4 x 4 x 4 (that
is, 43) is the same as entering the formula 4^3.
The exponent does not have to be a whole number; it can even be negative. For example, 2^2.1
returns 4.28709385014517, and 4^–2 is 0.0625.
The modulo division operator: Mod
The modulo operator (Mod) takes any two numbers (number1 and number2), rounds them up or
down to integers, divides the first by the second (number1 / number2), and then returns the
remainder. Here are some examples of how modulo division compares to normal division:
Normal Division Modulo Division Explanation
10 / 5 = 2 10 Mod 5 = 0 10 is evenly divided by 5
10 / 4 = 2.5 10 Mod 4 = 2 10 / 4 = 2 with a remainder of 2
22.24 / 4 = 5.56 22.24 Mod 4 = 2 22 / 4 = 5 with a remainder of 2
22.52 / 4 = 5.63 22.52 Mod 4 = 3 23 / 4 = 5 with a remainder of 3