# llSqrt

> lsl.dev (unofficial LSL docs). Full API: https://lsl.dev/api.json · Index for LLMs: https://lsl.dev/llms.txt

*LSL function*

```lsl
float float llSqrt(float val);
```

- `float val`: Positive float value (must be >= 0.0).

- Returns: `float`
- Energy: 10

For imaginary results (**val** &lt; 0.0), a [Math Error](https://wiki.secondlife.com/wiki/Category:LSL_Error/Math) is triggered under LSO , or 'NaN' (Not A Number) is returned under Mono

Returns a [float](https://wiki.secondlife.com/wiki/float) that is the square root of **val**.

```lsl title="How to use" frame="terminal"
float result = llSqrt(0.0);
```

## Caveats

- Crashes the script if passed a negative number.

## Examples

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

```lsl
default
{
  state_entry()
  {
    float num1 = llFrand(100.0);

    llOwnerSay("The square root of " + (string)num1 + " is " + (string)llSqrt(num1));
  }
}
```

</details>

## Notes

- If you need the square root of two, you can use the constant [SQRT2](/constants/SQRT2/).
- Other roots can be computed by [llPow](/functions/llPow/)(**val**, 1.0/**root**).

## See also

### Functions

- [llLog](/functions/llLog/)
- [llLog10](/functions/llLog10/)
- [llPow](/functions/llPow/)

---

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

---

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