Math operators
Four basic operations and remainder.
Syntax
+ - * / %
Description
The division of two integers is an integer (7/2=3). If you want a decimal, at least one must be a double (7.0/2.0=3.5). % gives the remainder.
Example
Loading editor…
Expected output
10 3 3.5 1
When to use?
Calculations, even/odd check (number % 2).
Common mistakes
- ⚠️ Integer division truncates the decimal; use double for decimals.