MOD/de
(Difference between revisions)
(Created page with "= <span class="f_Header">Action</span> = Calculates the remainder of a division. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;"> </s...") |
m (1 revision) |
Revision as of 21:15, 15 February 2013
Contents |
= (**COPIED FROM ENGLISH PAGE**) === Action
Calculates the remainder of a division.
Syntax
var1 = var2 MOD var3
Remarks
var1 |
Variable that will be assigned with the modules of var2 and var3. |
var2 |
A numeric variable to take the modules from |
var3 |
The modulus |
The MOD operation is similar to the division operation(/). But while a division returns the number of times a number can be divided, the MOD returns the remainder.
For example : 21 MOD 3 will result in 0 since 7x3=21. There will be no remainder.
But 22 MOD 3 will result in 1 since 22-(7x3)=1
In BASCOM, the variable you assign determines which kind of math will be used. When you have 2 word variables you want to get the modulus from, you have to assign a word variable too.
When you assign a byte, byte math will be used.
See also
Example
Dim L As Long , L2 As Long For L = 1 To 1000 L2 = L Mod 100 If L2 = 0 Then ' multiple of 100 Print L End If Next
Languages | English • Deutsch |
---|