0Pricing
Lua Academy · Lesson

Integers and Floats

How Lua represents numbers.

Numbers in Lua

In Lua, the number type holds all kinds of numeric values. You use numbers to count things, measure values, and do math.

Starting with Lua 5.3, numbers come in two flavors: integers (whole numbers) and floats (numbers with a decimal point).

Let's print a couple of numbers to begin.

print(10)
print(3.14)

What Is an Integer?

An integer is a whole number with no fractional part, like 0, 42, or -7.

When you write a number without a decimal point, Lua treats it as an integer.

  • 5 is an integer
  • -100 is an integer
local apples = 5
print(apples)

All lessons in this course

  1. Integers and Floats
  2. Arithmetic Operators
  3. The math Library
  4. Number Formatting
← Back to Lua Academy