You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/09/16 00:52:56 UTC

[05/13] git commit: Fixed TestSloppyMath.TestHaversin

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 <pr...@microsoft.com>
Authored: Thu Sep 11 16:23:26 2014 -0700
Committer: Prad Nelluru <pr...@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];
         }