FANDOM


NumberEdit

EssentialsEdit

A number is simply any number. It is not limited to integers, you may have numbers that have floating points as well.

SamplesEdit

Sample
The following proves Lua categorizes all numbers as numbers.

Source:

print(type(5.2))
print(type(5))
print(type(1/3))
print(type(-123))
Output:

number       number       number       number


Sample
This is an example of operations you can do with numbers.

Source:

print(2+2)
Output:

4


ExtraEdit

Here is a common programming issue.

Sample
The floating point issue

Source:

print(.1+.2==.3)
Output:

false


Lua thinks .1 + .2 doesn't equal .3! Why? This issue has its roots in the IEEE-754 standard for floating decimal point arithmetic. Most programming languages implements this standard (including C in which Lua was written in). Therefore Lua inherits this behavior.