Number (type)

From ComputerCraft Wiki
Revision as of 04:24, 6 September 2015 by Cranium (Talk | contribs) (int and float pages deleted, as info is on this page now)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A number is a data type which represents any real number (for example, 1, -900.1, or 13.37). There are a two types of different numbers that can be used within Lua programming.


An int (short for 'integer') is a data type which represents a real, absolute number.

An integer is a whole-number (without an express or implied decimal point). For example, 1, 5, -102 and 101283 are all integers. Numbers like 9.5, 8.3 and -53124.4 are not integers, they are floating point numbers.


Float (short for "floating point") is a data-type for numbers.

Floating point numbers are decimals; they have an expressed decimal point and value (regardless of the value after the decimal place). For example, 1.4 and 5.2 are floats, and 1.0, 5.0 and 1293.0 are also floating point numbers.

Numbers without an express (or in the case of a floating point number, implied) decimal point are integers.

More information

For a more in-depth and concise explanation of types, please consult the Lua 5.1 Official Manual.