Skip to content
lsl.devlsl.devLSL Dev

llFabs

function
Function syntax
float llFabs(
  1. float val// Number to convert.
);
Returns
float
Energy
10

Returns a float that is the positive version of val.

How to use
float result = llFabs(0.0);
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 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.

From the issue templates included by the wiki article:

  • SCR-439 (bug): Mono only: llFabs of Negative Zero is negative, should be positive.
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.

From the Second Life Wiki

Community documentation adapted from LlFabs, by Linden Research, Inc. and contributing residents.View contributors and history.

Built from these wiki pages, as imported:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.