Arithmetic ( + - * / % ^ )
Try it yourself →Four basic operations, modulo, and exponentiation.
Syntax
a + b, a % b, a ^ b
Description
^ is the exponentiation operator (result is a float). // is floor division (Lua 5.3+).
Example
print(7 % 2) print(2 ^ 10) print(7 // 2)
Expected output
1 1024.0 3
When to use?
Calculations.
Common mistakes
- ⚠️ ^ result is a float: 2^10 → 1024.0. Use math.floor or // for an integer.