llFabs
function
Function syntax
float llFabs(float val// Number to convert.
);- Returns
float- Energy
- 10
Returns a float that is the positive version of val.
float result = llFabs(0.0);Examples
Section titled “Examples”Example 1
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- Using
val-2*val*(val<0)is roughly 60% faster thanllFabsas 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.
Known issues
Section titled “Known issues”From the issue templates included by the wiki article:
- SCR-439 (bug): Mono only: llFabs of Negative Zero is negative, should be positive.
See also
Section titled “See also”Functions
Section titled “Functions”Articles
Section titled “Articles”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.