diff options
| author | Charles Karney <charles@karney.com> | 2017-12-18 17:56:24 -0500 |
|---|---|---|
| committer | Charles Karney <charles@karney.com> | 2017-12-18 17:56:24 -0500 |
| commit | 2162ad57c190f5c924eb61fa47325c48fd894832 (patch) | |
| tree | 88924ecc806a98f53e662403f41a5d9ca63fca61 /src/geodesic.c | |
| parent | ca9a448edc35149c1bdb5d90ffbdae88b43dadb1 (diff) | |
| download | PROJ-2162ad57c190f5c924eb61fa47325c48fd894832.tar.gz PROJ-2162ad57c190f5c924eb61fa47325c48fd894832.zip | |
Fix issue #715. Merge 1.49.1 of geodesic library (tagged as v1.49.1-c
in GeographicLib). Details:
Workaround bugs in handling of -0.0 in fmod and sin in Visual Studio 10,
11, and 12.
Relax unrealistically strict delta for GeodSolve59 in geodtest.
Diffstat (limited to 'src/geodesic.c')
| -rw-r--r-- | src/geodesic.c | 25 |
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; |
