# llAbs

*LSL function*

```lsl
integer integer llAbs(integer val);
```

- `integer val`: Integer to convert.

- Returns: `integer`
- Energy: 10

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is the positive version of **val**.

```lsl title="How to use" frame="terminal"
integer result = llAbs(0);
```

## Caveats

- The `llAbs` of -2147483648 is -2147483648. This is because the positive integer 2147483648 is outside the range of allowed LSL [integer values](https://wiki.secondlife.com/wiki/Category:LSL_Integer).

## Examples

<details open>
<summary>Example 1</summary>

```lsl
default
{
    state_entry()
    {
//      returns: "The absolute value of -4 is: 4"
        llSay(PUBLIC_CHANNEL, "The absolute value of -4 is: "+(string)llAbs(-4) );
    }
}
```

</details>

<details>
<summary>Example 2</summary>

```lsl
// Here's a more elaborate example.

ShowAbsolute(integer inputInteger)
{
    string output = "llAbs(" + (string)inputInteger + ") --> " + (string)llAbs(inputInteger);

    llSay(PUBLIC_CHANNEL, output);
}

default
{
    state_entry()
    {
        ShowAbsolute(-3);   //  llAbs(-3)  --> 3
        ShowAbsolute(5);    //  llAbs(5)   --> 5
        ShowAbsolute(-20);  //  llAbs(-20) --> 20
        ShowAbsolute(0);    //  llAbs(0)   --> 0
    }
}
```

</details>

## Notes

- Using `val-(val<<1)*(val<0)` is roughly two times faster than `llAbs`, as it avoids a function call and produces identical results.

## See also

### Functions

- [llFabs](/functions/llFabs/) — [float](https://wiki.secondlife.com/wiki/float) version of `llAbs`

### Articles

- [Absolute value](https://en.wikipedia.org/wiki/Absolute_value)

---

*Source: [LlAbs](https://wiki.secondlife.com/wiki/LlAbs) on the Second Life Wiki. Content from the Second Life Wiki article LlAbs (revision 1215184, 2023-10-28), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llAbs/
