Math.Mod |
Top Previous Next |
Syntax function Math.Mod(Op1, Op2: integer): integer
Alternative Names
Description Performs an integer division and returns the remainder.
The Return Value is the remainder when dividing the value in Op1 by the value in Op2.
See Also
Example execute UDSBlock as begin /* divide 10 by 3 > 10/3=3.33333, round down to 3 */ Res = Math.Div(10, 3); GUI.ShowMessage('Result (3): ' || Res);
/* divides 10 by 3 and returns the remainder > 10/3=3.3333, round down to 3 3x3=9 10-9=1 as the remainder */ Res = Math.Mod(10, 3); GUI.ShowMessage('Result (1): ' || Res);
/* prompt the user to input a number, then use Math.Mod to determine if it's an even or odd number */ InputNr = 11; GUI.InputQuery('Enter number', 'Enter an integer number: ', InputNr); Res = Math.Mod(InputNr, 2); if (Res = 0) then GUI.ShowMessage(InputNr || ' is an even number'); else GUI.ShowMessage(InputNr || ' is an odd number'); end |