Mod: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
JwellsNB (talk | contribs)
Add javasript snippet
JwellsNB (talk | contribs)
Line 23: Line 23:


var Answer;
var Answer;
Answer = (15*1)%(2*1);
Answer = 15 % 2;
NSB.Print("15 Mod 2 = " + Answer);
NSB.Print("15 Mod 2 = " + Answer);
Answer = (21*1)%(3.7*1);
Answer = 21 % 3.7;
NSB.Print("21 Mod 3.7 = " + Answer);
NSB.Print("21 Mod 3.7 = " + Answer);
</pre>
</pre>

Revision as of 01:56, 28 May 2013

result = x Mod y

Description

Mod divides x by y and returns the integer part of the remainder. The required parameters, x and y, are any valid numeric expressions. The value of result is a whole number with a magnitude less than the magnitude of y.

Example (Basic)

Rem Mod Example
'Mod returns quotient remainder as integer
Dim Answer
Answer = 15 Mod 2
Print "15 Mod 2 = " & Answer
Answer = 21 Mod 3.7
Print "21 Mod 3.7 = " & Answer

Example (JavaScript)

// Mod Example
/* Mod returns quotient remainder as integer */

var Answer;
Answer = 15 % 2;
NSB.Print("15 Mod 2 = " + Answer);
Answer = 21 % 3.7;
NSB.Print("21 Mod 3.7 = " + Answer);

Output

15 Mod 2 = 1
21 Mod 3.7 = 2.5