Since the goal is efficiency, you could save an operation by 

```
if (val < 0)
   val += 180;
else
   val -=180;
```