Integer: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(int short n' long)
Line 3: Line 3:


An '''integer''' is a [[variable]] that stores a whole number (in other words, a number without a decimal point.)
An '''integer''' is a [[variable]] that stores a whole number (in other words, a number without a decimal point.)
An '''integer''' is declared as:
    int someIntegerName;
a standard '''integer''' is also know as a 32-bit integer.
alternative types to '''integer''' are '''short''', which is a 16-bit integer taking up half the memory and with a half the range of values it is capable of storing, and '''long''', a 64-bit integer with double the range of values and double the memory usage.
Also,'''integers''', '''shorts''', and '''longs''' can be declared as ''unsigned'', this identifier eliminates the [[variable]]s ability to store negative values and doubles its capacity of positive values. Therefore if you know you wont need any negative values, an ''unsigned short'' will have just as good a range of values as an ''int'', and with half the memory usage.
The following are all valid:
    int normalInteger;
    unsigned int positiveInteger;
    short shortInteger;
    unsigned short positiveShort;
    long longInteger;
    unsigned long positiveLong;


==See Also==
==See Also==
[[Real]]s<br>
[[Real]]s<br>
[http://en.wikipedia.org/wiki/Integer Wikipedia information on integer]
[http://en.wikipedia.org/wiki/Integer Wikipedia information on integer]

Revision as of 13:35, 7 August 2005

Stub

This article or section is a stub. You can help by expanding it.

An integer is a variable that stores a whole number (in other words, a number without a decimal point.) An integer is declared as:

   int someIntegerName;

a standard integer is also know as a 32-bit integer. alternative types to integer are short, which is a 16-bit integer taking up half the memory and with a half the range of values it is capable of storing, and long, a 64-bit integer with double the range of values and double the memory usage.

Also,integers, shorts, and longs can be declared as unsigned, this identifier eliminates the variables ability to store negative values and doubles its capacity of positive values. Therefore if you know you wont need any negative values, an unsigned short will have just as good a range of values as an int, and with half the memory usage.

The following are all valid:

   int normalInteger;
   unsigned int positiveInteger;
   short shortInteger;
   unsigned short positiveShort;
   long longInteger;
   unsigned long positiveLong;


See Also

Reals
Wikipedia information on integer