Difference between revisions of "Category:Variables"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>JOG
imported>Lubronbrons
 
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
There are a few types of variables. Although you can declare a variable to be Short or Long, both produce the same result.
{{Update}}


[[Variable_types:_shortint|short]] varNameShort
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.


[[Variable_types:_longint|long]] varNameLong
Although you can [[Declaring_variables|declare a variable]] to be [[Short Integer|Short]], [[Long Integer|Long]], or [[Floating Point|Float]], all three will be stored like a [[Floating Point|float]].


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


Sizes of numbers that can be stored in each type:
long      -2,147,483,648 to 2,147,483,647
 
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.
 
Other than that, however, generally [[Long Integer|longs]] and [[Short Integer|shorts]] will be rounded off to the nearest integer (i.e. 1.25 becomes 1, 1.75 becomes 2), while [[Floating Point|floats]] will store the decimal data. However, if a variable is a Global, then it will ''always'' be a [[Floating Point|float]] and therefore will not round off the decimal values.
 
NOTE : Long ago, an OBSE developer mentioned that, internally, the engine stores ALL vars as floats. (QQuix) so it is no problem if you set short value above 32767, the maximum limit positive number is 2,147,483,647 (or hexadecimal 7FFF,FFFF16)


<pre>
==See Also==
short      -32,768 to 32,767
 
long      -2,147,483,648 to 2,147,483,647
[[Introduction to OBSE arrays]]
float      1.18E-38 to 3.40E38 (precision = 7 digits)
ref        an object reference</pre>


[[Category: Functions|Z]]
[[Category:Scripting]]
[[Category:Scripting]]
[[Category:Commands]]
[[Category:Commands]]

Latest revision as of 19:52, 9 March 2018


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.

NOTE : Long ago, an OBSE developer mentioned that, internally, the engine stores ALL vars as floats. (QQuix) so it is no problem if you set short value above 32767, the maximum limit positive number is 2,147,483,647 (or hexadecimal 7FFF,FFFF16)

See Also[edit | edit source]

Introduction to OBSE arrays

Pages in category "Variables"

The following 8 pages are in this category, out of 8 total.