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

LSL Wiki : llRound

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are
integer llRound(float value)

Returns value rounded to the nearest integer.

If value's decimal part is >= 0.5, then value is rounded to the next integer. If not, it is rounded down to the previous integer.

More precisely, if the absolute value of value's decimal is < 0.5, then value is rounded to the next integer closer to 0, otherwise it is rounded to the next integer further from 0.

Value Returns
-7.85 -8
1.29 1
584.32 584
685.96 686
9803.40928 9803

To always round up to the nearest integer, use llCeil. To always round down, use llFloor. To round the number towards zero typecast directly to integer.

//To round away from zero.
RoundOut(float in)
    integer out = (integer)in;
    return out + (out != in);
//This can be inlined if 'out' has already been declared
//out = (out != in) + (out = (integer)in);
//If 'out' hasn't been declared you can still inline, though it's less efficiant
//integer out = (integer)in;
//out += (out != in);

The usage of these functions can be tricky. For examples of potential issues see llFrand.

This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Math
There is no comment on this page. [Display comments/form]