Box the compass: Difference between revisions
Content added Content deleted
m (→{{header|Python}}: Spelling) |
(→{{header|Python}}: Modulo already handles the negatives.) |
||
Line 29: | Line 29: | ||
def degrees2compasspoint(d): |
def degrees2compasspoint(d): |
||
d = (d % 360) + 360/64 |
d = (d % 360) + 360/64 |
||
if d < 0: |
|||
d += 360 |
|||
majorindex, minor = divmod(d, 90.) |
majorindex, minor = divmod(d, 90.) |
||
majorindex = int(majorindex) |
majorindex = int(majorindex) |