Difference between revisions of "Category:Variables"
imported>JOG (I'm not starting an edit war over this, but NOW the page is wrong and misleading. DOUBLEs can store 32 bit longs perfectly fine and longs behave like longs from the modder's POV) |
imported>JOG (The issue is that all arithmetic operation are done as floating point operations with single precision, thus longs are cut to the 24bit mantissa when you use these. Boolean operations work fine.) |
||
Line 18: | Line 18: | ||
==See Also== | ==See Also== | ||
[[Introduction to OBSE arrays]] | [[Introduction to OBSE arrays]] | ||
Revision as of 16:23, 4 March 2011
This category has been marked by editors as one needing attention. Please see the Talk page for details. If you can update the category, please do so.
There are a few types of variables. Most store numbers, but the special Reference Variables stores something in the game world so you can run functions on it later.
Although you can declare a variable to be Short, Long, or Float, all three will be stored like a float.
This is significant, as floats have accuracy issues at very high or very low values. When dealing with shorts, this is irrelevant as their range is within the float's "accurate" range. On the other hand, longs may be expected to be accurate outside of the float's range, and they will not be.
To illustrate, the sizes of numbers that should be storable in each type:
short -32,768 to 32,767 long -2,147,483,648 to 2,147,483,647 float 1.18E-38 to 3.40E38 (precision = 7 digits)
As you can see, a long might be expected to have up to 10 digits, but a 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 will not behave as expected because it is actually a float. See the float article for more information on floats' accuracy, and see Long's Talk page for details on this discovery.
Other than that, however, generally longs and shorts will be rounded off to the nearest integer (i.e. 1.25 becomes 1, 1.75 becomes 2), while floats will store the decimal data. However, if a variable is a Global, then it will always be a float and therefore will not round off the decimal values.
See Also
Pages in category "Variables"
The following 8 pages are in this category, out of 8 total.