llFabs

From Second Life Wiki
Jump to navigation Jump to search

Summary

Function: float llFabs( float val );
0.0 Forced Delay
10.0 Energy

Returns a float that is the positive version of val.

• float val Any valid float value
This function is similar to functions (e.g. fabs) found in many other languages: 
C++
fabs

Examples

default
{
    state_entry()
    {
        llSay(0,"The (Float)absolute value of -4.5 is: "+(string)llFabs(-4.5) );
    }
}
// returns :
// The (Float)absolute value of -4.5 is: 4.500000

Notes

  • Using val-2*val*(val<0) is roughly 60% faster than llFabs as it avoids a function call, though it produces NaN if given an infinite value and (correctly) returns 0.0 instead of -0.0 when taking the absolute value of negative zero.

See Also

Functions

•  llAbs integer version of llFabs

Articles

•  "Wikipedia logo"Absolute value

Deep Notes

Signature

function float llFabs( float val );

Haiku

Even with all your little bits intact,
down to the final point
it's still size that matters.