Math operators
Try it yourself →Four basic operations, integer division, and remainder.
Syntax
+ - * / ~/ %
Description
/ always returns a decimal (double). Use ~/ for integer division. % gives the remainder (commonly used in even/odd checks).
Example
void main() {
print(7 + 3);
print(7 / 2);
print(7 ~/ 2);
print(7 % 2);
}Expected output
10 3.5 3 1
When to use?
Calculations, even/odd check (number % 2).
Common mistakes
- ⚠️ / returns a decimal; use ~/ if you want an integer result.