Math operators
Try it yourself →Four basic operations and remainder.
Syntax
+ - * / %
Description
Division of two integers is an integer (7/2=3). At least one must be a Double for decimal results. % gives the remainder.
Example
println(7 + 3) println(7 / 2) println(7.0 / 2.0) println(7 % 2)
Expected output
10 3 3.5 1
When to use?
Calculations, even/odd checks (x % 2).