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

LSL Wiki : integer

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org

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
Comments [Hide comments/form]
How long may an integer be? Can it be 40+/- digits ie. 235215296235221512967235215296235221512967

" Watch out! This will compile, but will result in x having the value of -1.
integer x = 12345678900000;" so how can we get around this?
-- Bobbyb30 (2007-03-22 17:44:15)
it seems if you have the same number of digits as the max value yet say have one or two points over it converts it to a negative and seems to put a random negative long integer out there...it does NOT return a -1, that only happens when you add an integer with more characters than the max number
-- hst000051067um.bus.olemiss.edu (2007-08-14 09:58:07)
FYI, this is Wolt Amat. Someone had pasted a whole list of porn sites into this page, I removed them.
-- 24.238.64.138.res-cmts.sth.ptd.net (2007-09-06 06:55:59)
Attach a comment to this page: