Slight error in calculations <p>I'm trying to build a game somewhat like Wheel of Fortune, actually it's done but there seems to a weird issue I can't figure out.</p> <p>Here's the wheel itself, as you can see the values are spaced evenly, each having a 15 &deg; slice.</p> <p><img src="https://i.stack.imgur.com/i2thO.png" alt="enter image description here"></p> <p>To spin the wheel I generate a random number which will be the amount of rotation in degrees, I animate the wheel and everything is fine but when the rotation stops I have to get the value from the wheel which stops at the top-center position so I though this would solve it:</p> <pre><code>wheelValues = [ 1000, 3250, 1800, 1000, 1200, 3750, 5000, 1000, 3000, 1600, 1000, 3500, 1000, 2000, 1000, 2750, 1000, 4000, -1, 1000, 2500, 1400, 1000, 2250 ]; if (toAngle &gt; 360) { toAngle = toAngle - (Math.floor(toAngle / 360) * 360); } arrIndex = Math.floor(toAngle / 15) + 1; result = wheelValues[arrIndex]; </code></pre> <p>where <code>toAngle</code> is the random spin I generate which can be between 370 and 1440.</p> <p>This method works in about 8/9 times out of 10 and I can actually get the correct value the wheel stops at but I can't really understand why sometimes the value is off (and sometimes really off, not even near the correct value).</p>