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.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.