lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [05/13] git commit: Fixed TestSloppyMath.TestHaversin
Date Mon, 15 Sep 2014 22:52:56 GMT
Fixed TestSloppyMath.TestHaversin

(int)Double.NaN is always 0 in Java. It's not guaranteed to be 0 in C#.
Modified the code so it's not dependent on this mechanic.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/be80c4e6
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/be80c4e6
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/be80c4e6

Branch: refs/heads/master
Commit: be80c4e63273daf809245d699f9a2c4bada2a46b
Parents: 2603ae8
Author: Prad Nelluru <prnell@microsoft.com>
Authored: Thu Sep 11 16:23:26 2014 -0700
Committer: Prad Nelluru <prnell@microsoft.com>
Committed: Thu Sep 11 16:23:26 2014 -0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/SloppyMath.cs | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/be80c4e6/src/Lucene.Net.Core/Util/SloppyMath.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/SloppyMath.cs b/src/Lucene.Net.Core/Util/SloppyMath.cs
index fe142a4..79d6417 100644
--- a/src/Lucene.Net.Core/Util/SloppyMath.cs
+++ b/src/Lucene.Net.Core/Util/SloppyMath.cs
@@ -1,5 +1,6 @@
 using Lucene.Net.Support;
 using System;
+using Double = System.Double;
 
 namespace Lucene.Net.Util
 {
@@ -158,6 +159,8 @@ namespace Lucene.Net.Util
         /// Return an approximate value of the diameter of the earth at the given latitude,
in kilometers. </summary>
         public static double EarthDiameter(double latitude)
         {
+            if(double.IsNaN(latitude)) 
+                return double.NaN;
             int index = (int)(Math.Abs(latitude) * RADIUS_INDEXER + 0.5) % EarthDiameterPerLatitude.Length;
             return EarthDiameterPerLatitude[index];
         }


Mime
View raw message