Difference between revisions of "Category:Variables"

859 bytes added ,  04:27, 17 September 2006
all number variables actually floats
imported>JOG
m
imported>DragoonWraith
(all number variables actually floats)
Line 1: Line 1:
There are a few types of variables. Although you can [[Declaring_variables|declare a variable]] to be [[Variable_types:_shortint|Short]] or [[Variable_types:_longint|Long]], both produce the same result.
There are a few types of variables. Most store numbers, but the special [[Reference Variable]] stores something in the game world so you can run functions on it later.


[[Variable_types:_shortint|short]] varNameShort
Although you can [[Declaring_variables|declare a variable]] to be [[Short Integer|Short]], [[Long Integer|Long]], or [[Floating Point|Float]], all three will act like a [[Floating Point|float]].


[[Variable_types:_longint|long]] varNameLong
This is significant, as [[Floating Point|floats]] have accuracy issues at very high or very low values. When dealing with [[Short Integer|shorts]], this is irrelevant as their range is within the float's "accurate" range. On the other hand, [[Long Integer|longs]] may be expected to be accurate outside of the [[Floating Point|float]]'s range, and they will not be.


[[Variable_types:_floating_point|float]] varNameFloat
To illustrate, the sizes of numbers that should be storable in each type:
 
<pre>short      -32,768 to 32,767
[[Variable_types:_reference_variables|ref]] varNameRef
 
Sizes of numbers that can be stored in each type:
 
<pre>
short      -32,768 to 32,767


long      -2,147,483,648 to 2,147,483,647  
long      -2,147,483,648 to 2,147,483,647  


float      1.18E-38 to 3.40E38 (precision = 7 digits)  
float      1.18E-38 to 3.40E38 (precision = 7 digits)</pre>
 
As you can see, a [[Long Integer|long]] might be expected to have up to 10 digits, but a [[Floating Point|float]] will not accurately display more than 7 (it can, however, accurately show a number of less than eight digits followed by twenty or more zeros, if necessary), and so a [[Long Integer|long]] will '''not''' behave as expected because it is actually a [[Floating Point|float]]. See the [[Floating Point|float article]] for more information on floats' accuracy, and see [[Talk:Long Integer|Long's Talk page]] for details on this discovery.
ref        an object reference</pre>


[[Category:Scripting]]
[[Category:Scripting]]
[[Category:Commands]]
[[Category:Commands]]
[[Category:Functions]]
[[Category:Functions]]