From 9e88e9cb60993fa18bc47ddb4a82e69014509085 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 18 Jan 2016 15:57:21 -0500 Subject: [PATCH] - Fixed: Undefined negative double to unsigned int conversion in PointToAngle. --- main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 406f56a..118f16e 100644 --- a/main.cpp +++ b/main.cpp @@ -688,7 +688,8 @@ angle_t PointToAngle (fixed_t x, fixed_t y) double ang = atan2 (double(y), double(x)); const double rad2bam = double(1<<30) / M_PI; double dbam = ang * rad2bam; - return angle_t(dbam) << 1; + // Convert to signed first since negative double to unsigned is undefined. + return angle_t(int(dbam)) << 1; } //==========================================================================