Difference between revisions of "MOD"

From QB64 Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
'''MOD''' is mathematical Integer remainder division. Also called Modulus, it can work with integer division when a remainder is necessary.
 
'''MOD''' is mathematical Integer remainder division. Also called Modulus, it can work with integer division when a remainder is necessary.
 +
  
 
''Syntax:'' Numerator MOD Divisor
 
''Syntax:'' Numerator MOD Divisor
 +
  
 
MOD returns 0 if a number is evenly divisible by Integer division (\).
 
MOD returns 0 if a number is evenly divisible by Integer division (\).
 
MOD returns 0 if the numerator is 0. The divisor should never be 0!
 
MOD returns 0 if the numerator is 0. The divisor should never be 0!
 
Otherwise it returns only the remainder as an Integer.
 
Otherwise it returns only the remainder as an Integer.
 +
  
 
''Example:'' a% = 100 MOD 9: b% = 100 \ 9
 
''Example:'' a% = 100 MOD 9: b% = 100 \ 9
  
 
''Results:'' a% = 1: b% = 11
 
''Results:'' a% = 1: b% = 11

Revision as of 08:27, 28 August 2009

MOD is mathematical Integer remainder division. Also called Modulus, it can work with integer division when a remainder is necessary.


Syntax: Numerator MOD Divisor


MOD returns 0 if a number is evenly divisible by Integer division (\). MOD returns 0 if the numerator is 0. The divisor should never be 0! Otherwise it returns only the remainder as an Integer.


Example: a% = 100 MOD 9: b% = 100 \ 9

Results: a% = 1: b% = 11