Can You Find Something Mod 2Pi in JavaScript?
<p>EDIT: I have an angle from using Math.atan2() which I then want to add or subtract values from. However, this addition and subtraction sometimes means the angle is greater that pi or less than -pi and I'm looking for a way to get one of these outside angles back into the correct range.</p>

<p>I'm trying to find a value mod 2pi in JavaScipt using the following code:</p>

<pre><code>foo % Math.PI * 2;
</code></pre>

<p>However, it always just returns foo, even if I try this:</p>

<pre><code>var bar = Math.PI * 2;
foo % bar;
</code></pre>

<p>Can anyone explain to me why this doesn't work?</p>

<p>DLiKS</p>
