Degrees
BlitzMax Forums/BlitzMax Beginners Area/Degrees
| ||
Hi, I have a value 'degrees#' which could be any value. What is the best way to make it between 0.0 and 359.9999999... But still the same if you know what I mean. |
| ||
degrees:Mod 360 which is the same as degrees = degrees Mod 360 Example degrees = 365 degrees:Mod 360 Result = 5. |
| ||
Gfk does Mod not work only on integers? Need floating point. |
| ||
Gfk does Mod not work only on integers? Nope, it'll work fine. |
| ||
It does, however, return results in the range -360 to +360. A Mod M will have the same sign as A. So if you want 0 to 360 you can do A Mod 360 and test the result. If negative then add 360. Another possibility is ( ( A Mod 360) + 360 ) Mod 360. The + 360 ensures a non-negative value. |
| ||
Thanks |