Number: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Pighead10
No edit summary
>Flurite
No edit summary
Line 1: Line 1:
{{CatUp|Data Types}}
{{CatUp|Data Types}}


A '''Number''' in Lua is a [http://en.wikipedia.org/wiki/Double_precision_floating-point_format double precision floating point] number (or just 'double'). Every Lua variable that is simply a number (not a Vector3, just a number) with or without decimal places, negative or positive, is a double.  
A '''Number''' in Lua is a [http://en.wikipedia.org/wiki/Double_precision_floating-point_format double precision floating point] number (or just 'double'). Every Lua variable that is simply a number (not a Vector3, just a number) with or without decimal places, negative or positive, is a double. Here are some examples of numbers:
 
{{Example|
<pre>
5,
9.12761656
-1927
</pre>
}}


Doubles can range from 1.7E–308 to 1.7E+308 (that's around 15 digits, positive or negative). In most cases, this is easily big enough for what you need it for - 15 digits is about one hundred trillion, so you won't need much bigger than that. It is not possible to go out of this limit.
Doubles can range from 1.7E–308 to 1.7E+308 (that's around 15 digits, positive or negative). In most cases, this is easily big enough for what you need it for - 15 digits is about one hundred trillion, so you won't need much bigger than that. It is not possible to go out of this limit.

Revision as of 01:29, 10 January 2012

A Number in Lua is a double precision floating point number (or just 'double'). Every Lua variable that is simply a number (not a Vector3, just a number) with or without decimal places, negative or positive, is a double. Here are some examples of numbers:

Example
5,
9.12761656
-1927


Doubles can range from 1.7E–308 to 1.7E+308 (that's around 15 digits, positive or negative). In most cases, this is easily big enough for what you need it for - 15 digits is about one hundred trillion, so you won't need much bigger than that. It is not possible to go out of this limit.

Certain Properties in Roblox require a whole number, or a positive number. In such cases an Integer will be asked for, instead of a number. If the number in your script doesn't have a decimal place and fits within the range of a Roblox property that required an integer, it will be converted to an integer.

Additionally, arithmetic operators can be applied to Numbers. Multiplication (*), Division (/), Subtraction (-), Addition (+), and Modulo (%). Comparative operators (<, >, >=, <=) can also be applied to numbers.