# llCos

*LSL function*

```lsl
float float llCos(float theta);
```

- `float theta`: Angle in radians.

- Returns: `float`
- Energy: 10

Returns the cosine of theta. Theta is in radians.

Returns a [float](https://wiki.secondlife.com/wiki/float) that is the cosine of **theta**.

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

## Caveats

because of IEE754 on single floats, `llCos(PI_BY_TWO)` returns -4.371139E-8 (hex : 0xB33BBD2E ) and not 0 ; `llCos(PI/3.0)` returns 0.49999997 ( hex : 0x3EFFFFFF ) and not 0.5

## Examples

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

```lsl
// Touch the object with this script in it to see the cosine of random numbers!
default
{
    touch_start(integer num)
    {
        float r = llFrand(TWO_PI);
        llOwnerSay("The cosine of " + (string)r + " in radians or " + (string)(r * RAD_TO_DEG) + " in degrees is " + (string)llCos(r));
    }
}
```

</details>

## See also

### Functions

- [llSin](/functions/llSin/) — [llAsin](/functions/llAsin/) — sine & inverse Sine
- [llAcos](/functions/llAcos/) — inverse cosine
- [llTan](/functions/llTan/) — [llAtan2](/functions/llAtan2/) — tangent & inverse tangent

---

*Source: [LlCos](https://wiki.secondlife.com/wiki/LlCos) on the Second Life Wiki. Content from the Second Life Wiki articles LlCos (revision 1197474, 2015-09-14) and Template:LSL Function/angle (revision 1169077, 2012-06-13), CC BY-SA 3.0.*

---

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