Arithmetic, DIV and MOD · 算术、DIV 与 MOD
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
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
English
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).
中文
DIV 和 MOD 写在两个数中间
DIV是整数除法:一个数里能装下另一个数多少个整次。MOD是余数。- 在这份指南里,它们写在两个数中间:
17 DIV 5,17 MOD 5。 - IGCSE 0478 不是这样写的。那边它们是函数
DIV(17, 5)。
English
中文
OUTPUT 17 DIV 5
OUTPUT 17 MOD 5
English
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.
中文
INT 去掉小数部分
INT(x)返回一个实数的整数部分。INT(27.5415)是27。RAND(n)返回一个从 0 到n(不含n)的实数。结果可以变化时,试卷才会用它。
OUTPUT INT(27.5415)
English
Common mistakes
- Write
17 DIV 5, notDIV(17, 5), on a 9618 paper. - Use parentheses when the order of a long expression matters.
中文
常见错误
- 在 9618 试卷上写
17 DIV 5,不要写DIV(17, 5)。 - 长算式的运算顺序要紧时,加上括号。
English
Now you try
- Use
DIV,MODandINT.
中文
现在你来试
- 使用
DIV、MOD和INT。
Output · 输出 17 DIV 5 and 17 MOD 5, each on its own line. · 分别输出 17 DIV 5 和 17 MOD 5,各占一行。
Click Run to see the output here. · 点击“运行”查看此处输出。
Output the integer part of 27.5415. · 输出 27.5415 的整数部分。
Click Run to see the output here. · 点击“运行”查看此处输出。