runtime: Math.Atan bug
I’m not sure if this is the right place to post this, but I’m running .NET Framework 4.7.2 and I’m getting a weird bug where Math.Atan sometimes returns the wrong value. Each time I’ve tested it, the value returned should be -1.5707 but sometimes it returns 1.5707.
double rise = point2.Y - point1.Y;
rise = Math.Round(rise * Math.Pow(10, 4)) / Math.Pow(10, 4);
double run = point2.X - point1.X;
run = Math.Round(run * Math.Pow(10, 4)) / Math.Pow(10, 4);
double angle = Math.Atan(rise / run);
When testing this the rise was always negative and the run was zero (I checked to make sure it wasn’t just really small).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (13 by maintainers)
@danmosemsft Thank you so much!
Also, I managed to get the results I was expecting. Thank you all so much for the help!