Edge Numbers

Some handy numbers to remember the range of the data types.

Integer min: -2147483648
integer max: 2147483647

The following are the integer equivalents of the 23 bit significand of the floats,
with a 24th bit implicit because of the normalized form.
I.e. this is the range of integer numbers a float can represent before they
start to "cluster" due to precision loss; slightly more than 7 digits in decimal.
(Note that conversion and readout to decimal will act strange immediately above 7 digits, even if the
internal representation can handle a bit more).

Float full precision min: -16777216
Float full precision max: 16777215

(See the description of binary representation for an explanation of the specific numbers).

Random Numbers

And similarly, since the limited precision often blindsides people who are trying to pick a random integer, here is some code to do common tasks:

Random number with full precision

Since a float does not have enough precision to represent the entire spread of an integer, we cannot use llFrand directly to pick a random number in the full integer range.
Hence, we use a little bit-magic to generate it 16 bits at a time.

integer r = (((integer)llFrand(65536)) << 16) | ((integer)llFrand(65536))

Random chat channel

This one chooses a random 31 bit pattern, less the highest and lowest possible integer value.
It will always leave the 17th bit set, ensuring that we'll not get any numbers in the low, easily hand-written +/- 65536 range, and it will never hit the full 2147483647, which is used for debug channel.
It will be positive or negative at random, as a random bit is shifted into the sign position.

integer channel = (((integer)llFrand(32768)) << 17) | 65536 | ((integer)llFrand(65535));