version 6.0
An expression that uses a numeric operator returns a number. The following table shows the numeric operators:
Operation | Syntax | Returns | Expression | Value |
Addition | Number + Number | Number | 2 + 3 | 5 |
Subtraction | Number Number | Number | 3 2 | 1 |
Multiplication | Number * Number | Number | 5 * 2 | 10 |
Division | Number /Number | Number | 5 / 2 | 2.5 |
Longint division | Number \ Number | Number | 5 \ 2 | 2 |
Modulo | Number % Number | Number | 5 % 2 | 1 |
Exponentiation | Number ^ Number | Number | 2 ^ 3 | 8 |
Modulo Operator
The modulo operator % divides the first number by the second number and returns a whole number remainder. Here are some examples:
10 % 2 returns 0 because 10 is evenly divided by 2.
10 % 3 returns 1 because the remainder is 1.
10.5 % 2 returns 0 because the remainder is not a whole number.
WARNING:
The modulo operator % returns significant values with numbers that are in the Long Integer range (from minus 2^31 to 2^31 minus one). To calculate the modulo with numbers outside of this range, use the Mod command.
The longint division operator \ returns significant values with integer numbers only.
See Also
Bitwise Operators, Comparison Operators, Date Operators, Logical Operators, Operators, Picture Operators, String Operators, Time Operators.