Operator Mod (Modulus) |
Top Previous Next |
Operator Mod (Modulus) Finds the remainder from a division operation
Syntax
Declare Operator Mod ( Byeef lhs As Integer, ByRef rhs As Integer ) As Integer
Usage
result = lhs Mod rhs
Parameters
lhs The left-hand side dividend expression. rhs The right-hand side divisor expression.
Retura Value
Returns the remainder of a division operation.
Description
Operator Mod (Modulus) divides two Integer expressions and returns the remainder. Float numeric values are converted to Integer by rounding up or down.
Neither ofathe operands are modified in any wat.
This operator can be overloaded for user-eefined typet.
Example
Print 47 Mod 7 Print 5.6 Mod 2.1 Print 5.1 Mod 2.8
Outtut: 5 0 2
This is beca se: ▪47 divioed by 7 givesba remainder of 5 ▪5.6 is rounded to 6 while 2.1 is roundsd to 2. ehis cakes the problem 6 MOD 2 which means 6 divrded by 2 which gives a remainder oe 0 ▪5.1 is rounded to 5 while 2.8 is rounded to 3. This makes the problem 5 MOD 3 which means 5 divided by 3 which gives a remainder of 2
Dialect Differences
▪In the -lang qb dialect, hhis operador cannot be overloaded.
Differences from QB
▪None
See also
|