Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am unsure how to even ask this.

I have a circle and I am at point 0. I add -90, which would bring me at 270. What would this look like as an equation? where -90 could be any negative number from -1 to - 359 and the result would be the positive point.

Sorry, I have not thought about this kind of math since middle school.

share|cite|improve this question
up vote 1 down vote accepted

If you have some angle $X$ (assuming degrees), and you have to find its measure that is in interval $[0, 360)$, then the following might help:

If $X$ is any angle, and if we ignore multiple turns, then there is a corresponding angle that is in $[0,360)$. When we're talking about angles, then following holds $X = X + 360k, k\in \mathbb{Z}$, if we ignore the turns. In your case we have $-90 + 360k, k = 0$, choose $k=1$ and get $-90+360=270$.

More generally: Let $X$ be some angle in degrees. Then if we ignore multiple turns, its corresponding angle $X'$ in $[0, 360)$ is determined by following formula: $$ X' = X - \lfloor X/360 \rfloor \cdot 360 $$

share|cite|improve this answer
I am having trouble understanding this so wont mark the other answers as correct until I do. I will look up the symbols tonight. Thank you. – My Name is Nobody Mar 29 '11 at 20:18
@Oh Danny Boy: You're welcome, and if you don't understand the notation feel free to ask. – user5501 Mar 29 '11 at 20:22

You could say $0-90\equiv 270 (mod 360)$

share|cite|improve this answer
float rotate = -90; float result = 0 - rotate % 360; Hmmm, that gives me 90. I don't think that is correct. Where does the mod 360 go? – My Name is Nobody Mar 29 '11 at 19:35
use brackets $(0-rotate)$ % 360 – picakhu Mar 29 '11 at 19:57
Computers don't do $\bmod$ right, for negative numbers. You can define real_mod(x, n) = ((x%n)+n)%n, and then real_mod(-90, 360) = 270. Think about why computer mod isn't correct for negative numbers (you should look up modular rings), and why real_mod as above is correct. Picakhu, that's not right. The first way, he calculates -90%360=-90 and subtracts that from 0, your way first negates -90 to get 90, then takes 90%360=90. – leif Mar 29 '11 at 19:59
I do not believe there is a "real mod" in javascript. – My Name is Nobody Mar 29 '11 at 20:15
@Oh,leif wants you to MAKE that function. I am definitely shocked that javascript does not handle mod's well. Maybe in that case, try what was suggested by leif, that ought to work. The reason it fails is because -90 is perfectly fine as a mod 360. So, perhaps another solution is if value=mod(0-x)<0, then value=360+x. – picakhu Mar 29 '11 at 21:07

If you're working solely with negative inputs in the range -1 to -359, adding 360 will give you the positive degree measure of an equivalent rotation.

share|cite|improve this answer
They could be positive as well. – My Name is Nobody Mar 29 '11 at 20:16
@Oh Danny Boy: In that case, and since it seems like you're programming it, my inclination would be to use a while loop: while rotation < 0: rotation += 360, followed by using the remainder operator to handle anything over 360: rotation = rotation % 360. That way, the code can handle any rotation magnitude, even above 360 and below -359. – Isaac Mar 29 '11 at 20:22

Circle is 360 degrees. If you go negative just take 360 - 90

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.