Math operators
Four basic operations and remainder.
Syntax
+ - * / %
Description
Division of two integers results in an integer (7/2=3). If you want decimals, 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 decimals; use Double for decimals.