Arithmetic ( + - * / % )
Try it yourself →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
package main
import "fmt"
func main() {
fmt.Println(7 % 2)
fmt.Println(7 / 2)
}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.