Difference between revisions of "Number (type)"

From ComputerCraft Wiki
Jump to: navigation, search
(Merged Float and Int together.)
(int and float pages deleted, as info is on this page now)
 
Line 1: Line 1:
{{NeedsWork|This article needs more information before the {{type|int}} and {{type|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.
 
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.
  

Latest revision as of 04:24, 6 September 2015

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.