Arithmetic Operators
Add, subtract, multiply, divide.
Doing Math in Lua
Lua gives you a full set of arithmetic operators to combine numbers. They work much like the math you already know.
In this lesson you will use them to add, subtract, multiply, divide, and more.
print(2 + 3)
print(10 - 4)Addition and Subtraction
The + operator adds two numbers and - subtracts them.
You can mix integers and floats freely. If either side is a float, the result becomes a float.
local total = 5 + 2.5
print(total)All lessons in this course
- Integers and Floats
- Arithmetic Operators
- The math Library
- Number Formatting