aboutsummaryrefslogtreecommitdiff
path: root/src/geodesic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/geodesic.c')
-rw-r--r--src/geodesic.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/geodesic.c b/src/geodesic.c
index 84951d7f..233dc34c 100644
--- a/src/geodesic.c
+++ b/src/geodesic.c
@@ -185,8 +185,18 @@ static real AngNormalize(real x) {
x = remainder(x, (real)(360));
return x != -180 ? x : 180;
#else
- x = fmod(x, (real)(360));
- return x <= -180 ? x + 360 : (x <= 180 ? x : x - 360);
+ real y = fmod(x, (real)(360));
+#if defined(_MSC_VER) && _MSC_VER < 1900
+ /*
+ Before version 14 (2015), Visual Studio had problems dealing
+ with -0.0. Specifically
+ VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0
+ sincosdx has a similar fix.
+ python 2.7 on Windows 32-bit machines has the same problem.
+ */
+ if (x == 0) y = x;
+#endif
+ return y <= -180 ? y + 360 : (y <= 180 ? y : y - 360);
#endif
}
@@ -231,6 +241,17 @@ static void sincosdx(real x, real* sinx, real* cosx) {
r *= degree;
/* Possibly could call the gnu extension sincos */
s = sin(r); c = cos(r);
+#if defined(_MSC_VER) && _MSC_VER < 1900
+ /*
+ Before version 14 (2015), Visual Studio had problems dealing
+ with -0.0. Specifically
+ VC 10,11,12 and 32-bit compile: fmod(-0.0, 360.0) -> +0.0
+ VC 12 and 64-bit compile: sin(-0.0) -> +0.0
+ AngNormalize has a similar fix.
+ python 2.7 on Windows 32-bit machines has the same problem.
+ */
+ if (x == 0) s = x;
+#endif
switch ((unsigned)q & 3U) {
case 0U: *sinx = s; *cosx = c; break;
case 1U: *sinx = c; *cosx = -s; break;