Unofficial LSL Reference

[[functions:llfabs]]


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

Function: llFabs

float llFabs(float fval)

Return the absolute value of the parameter (for floats).

Parameters

fval

Any float value (can be negative)

Return value

Returns a float that is the absolute value of fval, that is, the value with any negative sign removed.

More rigorously, the result will be the same as fval if fval is positive or zero, and -fval if it is negative.

Notes

  • To determine the absolute value of an integer, use llAbs.
  • "Minus zero" (-0.0) is a special case of a float that can rarely appear in some situations. The absolute value of Minus zero is returned by this function unchanged (as -0.0). This should not be a concern anyway, as minus zero is mostly transparent to all calculations (e.g. minus zero is considered equal to zero, and doesn't err when taking its square root).
  • The absolute value of NaN is NaN. The absolute value of Infinity and -Infinity is Infinity.

Short examples

float F = -2.25;
F = llFabs(F); // sets F to 2.25
F = llFabs(F); // F is still 2.25 because it was already positive
F = llFabs(0.0); // sets F to zero
F = llFabs(-PI); // sets F to approx. 3.141593
F = llFabs(0.5); // sets F to 0.5

See also