# Constrain angle to between -180 and 180

**URL:** <https://forum.kirupa.com/t/constrain-angle-to-between-180-and-180/298938>\
**Category:** flash\
**Created:** [October 27, 2009, 2:08pm UTC](https://forum.kirupa.com/t/constrain-angle-to-between-180-and-180/298938 "2009-10-27T14:08:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IQAndreas](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@IQAndreas](https://forum.kirupa.com/u/IQAndreas)\
**Post date:** [October 27, 2009, 2:08pm UTC](https://forum.kirupa.com/t/constrain-angle-to-between-180-and-180/298938/1 "2009-10-27T14:08:48Z")

</div>

I’m at a bit of a coders block, and I’m sure it’s quite simple. 😛

I tried using the following:

```auto
((angle-180)%360) + 180

```

But for angles \< 180 degrees, it works just fine, but after that it get’s a little funny. I know why it’s doing that, I’m just looking for a way to fix it.

Is there any way to do it quickly without 6 lines of codes containing if statements? The code should be as efficient as possible.
