Unofficial LSL Reference

[[functions:llround]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

This is an old revision of the document!


Function: llRound

integer llRound(float fval)

Round a float to the nearest integer.

Parameters

fval

The float value to be rounded.

Result

Returns the integer value that is the nearest to fval. If the decimal part is exactly .5, it will be rounded up (towards positive infinity).

Notes

  • The function returns -2147483648 (Hex. 80000000) for float values of 2147483648.0 or bigger, or less than -2147483648.0.

Short examples

integer i;
i = llRound(-3.3);   // i will become -3
i = llRound(3.3);    // i will become 3
i = llRound(3.5);    // i will become 4
i = llRound(-3.5);   // i will become -3
i = llRound(-99.6);  // i will become -100

See also

  • llCeil rounds always towards positive infinity (e.g. 1.1 is rounded up to 2.0, and -1.1 is rounded up to -1.0).
  • llFloor rounds always towards negative infinity (e.g. 1.1 is rounded down to 1.0 and -1.1 is rounded down to -2.0).
  • float type and associated caveats and limitations.