Don't click here unless you want to be banned.

LSL Wiki : integer

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ec2-204-236-235-245.compute-1.amazonaws.com

Integer

An integer is a signed, 32-bit value with valid range from -2147483648 to 2147483647 (that is 0x80000000 to 0x7FFFFFFF in hex). LSL does not have an unsigned integer type.

Examples:
10
122
-59438
0x5465

An integer is a whole number (no decimals). If you want decimals, you want a float.

As of Second Life 1.5, integers can be entered in hexadecimal (e.g. 0xff, 0x10, 0xF0AB, 0x20baef49 etc...) Strings typecast to integers also take these formats into account.

Example:
integer dec = 42; // 42 decimal
integer hex = 0xff; // 255 decimal

Octal support was added in 1.5.0 and removed in 1.5.2 because it caused incompatabilities with some existing scripts. The Lindens have not mentioned any plans to bring it back.

To round a float to an integer, use llRound.

Beware, a integer variable assigned a value larger/smaller than the valid range is instead assigned a value of -1.
// Watch out! This will compile, but will result in x having the value of -1.
integer x = 12345678900000;


Types | Bitwise | Bitfield | Binary | Memory Usages
There are 3 comments on this page. [Display comments/form]