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 2015/04/19 16:30:07 UTC
[1/2] lucenenet git commit: detect NaN and return appropriate value
Repository: lucenenet
Updated Branches:
refs/heads/master c0aa821d4 -> c7b14909f
detect NaN and return appropriate value
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/dedfe73b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/dedfe73b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/dedfe73b
Branch: refs/heads/master
Commit: dedfe73be77d4779a131a01a41425ef7738ec909
Parents: c0aa821
Author: Laimonas Simutis <la...@gmail.com>
Authored: Sat Apr 18 20:46:04 2015 -0400
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Sat Apr 18 20:46:04 2015 -0400
----------------------------------------------------------------------
src/Lucene.Net.Core/Support/Number.cs | 15 +++++++++++++++
src/Lucene.Net.Core/Util/NumericUtils.cs | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/dedfe73b/src/Lucene.Net.Core/Support/Number.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Number.cs b/src/Lucene.Net.Core/Support/Number.cs
index 7b689d9..4d19e36 100644
--- a/src/Lucene.Net.Core/Support/Number.cs
+++ b/src/Lucene.Net.Core/Support/Number.cs
@@ -424,6 +424,11 @@ namespace Lucene.Net.Support
public static int FloatToIntBits(float value)
{
+ if (float.IsNaN(value))
+ {
+ return 0x7fc00000;
+ }
+
// TODO it is claimed that this could be faster
return BitConverter.ToInt32(BitConverter.GetBytes(value), 0);
}
@@ -438,6 +443,16 @@ namespace Lucene.Net.Support
return BitConverter.DoubleToInt64Bits(value);
}
+ public static long DoubleToLongBits(double value)
+ {
+ if (double.IsNaN(value))
+ {
+ return 0x7ff8000000000000L;
+ }
+
+ return BitConverter.DoubleToInt64Bits(value);
+ }
+
//Flips the endianness from Little-Endian to Big-Endian
//2 bytes
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/dedfe73b/src/Lucene.Net.Core/Util/NumericUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/NumericUtils.cs b/src/Lucene.Net.Core/Util/NumericUtils.cs
index a806358..f92c1cb 100644
--- a/src/Lucene.Net.Core/Util/NumericUtils.cs
+++ b/src/Lucene.Net.Core/Util/NumericUtils.cs
@@ -278,7 +278,7 @@ namespace Lucene.Net.Util
/// <seealso cref= #sortableLongToDouble </seealso>
public static long DoubleToSortableLong(double val)
{
- long f = BitConverter.DoubleToInt64Bits(val);
+ long f = Number.DoubleToLongBits(val);
if (f < 0)
{
f ^= 0x7fffffffffffffffL;
[2/2] lucenenet git commit: match expected order in Lucene
Posted by sy...@apache.org.
match expected order in Lucene
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c7b14909
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c7b14909
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c7b14909
Branch: refs/heads/master
Commit: c7b14909fb0e8ff15f15db82359ffe2dfc8e5342
Parents: dedfe73
Author: Laimonas Simutis <la...@gmail.com>
Authored: Sat Apr 18 21:16:28 2015 -0400
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Sat Apr 18 21:16:28 2015 -0400
----------------------------------------------------------------------
src/Lucene.Net.Tests/core/Util/TestNumericUtils.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c7b14909/src/Lucene.Net.Tests/core/Util/TestNumericUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestNumericUtils.cs b/src/Lucene.Net.Tests/core/Util/TestNumericUtils.cs
index fc3c28a..b90c4b0 100644
--- a/src/Lucene.Net.Tests/core/Util/TestNumericUtils.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestNumericUtils.cs
@@ -165,7 +165,7 @@ namespace Lucene.Net.Util
[Test]
public virtual void TestDoubles()
{
- double[] vals = new double[] { double.NaN, double.NegativeInfinity, -2.3E25, -1.0E15, -1.0, -1.0E-1, -1.0E-2, -0.0, +0.0, 1.0E-2, 1.0E-1, 1.0, 1.0E15, 2.3E25, double.PositiveInfinity };
+ double[] vals = new double[] { double.NegativeInfinity, -2.3E25, -1.0E15, -1.0, -1.0E-1, -1.0E-2, -0.0, +0.0, 1.0E-2, 1.0E-1, 1.0, 1.0E15, 2.3E25, double.PositiveInfinity, double.NaN };
long[] longVals = new long[vals.Length];
// check forward and back conversion
@@ -199,7 +199,7 @@ namespace Lucene.Net.Util
[Test]
public virtual void TestFloats()
{
- float[] vals = new float[] { float.NaN, float.NegativeInfinity, -2.3E25f, -1.0E15f, -1.0f, -1.0E-1f, -1.0E-2f, -0.0f, +0.0f, 1.0E-2f, 1.0E-1f, 1.0f, 1.0E15f, 2.3E25f, float.PositiveInfinity };
+ float[] vals = new float[] { float.NegativeInfinity, -2.3E25f, -1.0E15f, -1.0f, -1.0E-1f, -1.0E-2f, -0.0f, +0.0f, 1.0E-2f, 1.0E-1f, 1.0f, 1.0E15f, 2.3E25f, float.PositiveInfinity, float.NaN };
int[] intVals = new int[vals.Length];
// check forward and back conversion