Arithmetic ( + - * / % )
Four basic operations and remainder.
Syntax
a + b, a % b
Description
Standard operators. Integer division truncates the decimal. math.Pow is used for exponents (there is no **).
Example
Loading editor…
Expected output
1 3
When to use?
Calculations, even/odd (% 2).
Common mistakes
- ⚠️ There is no ** in Go; use math.Pow(2, 10) for exponents.