Arithmetic, DIV and MOD
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
The arithmetic operators
+-*/and^are the ordinary arithmetic operators./gives a real result, even when both numbers are integers.^raises to a power.
OUTPUT 6 + 2
OUTPUT 7 / 2
OUTPUT 2 ^ 10
DIV and MOD sit between the numbers
DIVis integer division: how many whole times one number fits into another.MODis the remainder.- In this guide they are written between the two numbers:
17 DIV 5,17 MOD 5. - That is not how IGCSE 0478 writes them. There they are functions,
DIV(17, 5).
OUTPUT 17 DIV 5
OUTPUT 17 MOD 5
INT drops the fractional part
INT(x)returns the integer part of a real.INT(27.5415)is27.RAND(n)returns a real from 0 up to, but not including,n. A paper uses it when the result may vary.
OUTPUT INT(27.5415)
Common mistakes
- Write
17 DIV 5, notDIV(17, 5), on a 9618 paper. - Use parentheses when the order of a long expression matters.
Now you try
- Use
DIV,MODandINT.
Output 17 DIV 5 and 17 MOD 5, each on its own line.
Click Run to see the output here.
Output the integer part of 27.5415.
Click Run to see the output here.