Number (type)

From ComputerCraft Wiki
Revision as of 10:04, 22 May 2013 by Cranium (Talk | contribs) (Merged Float and Int together.)

Jump to: navigation, search
This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: This article needs more information before the int and float are removed. Please create a nice Table of Contents as well.)

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.

int

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

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.