This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit cb4bc0c5abeecbb747c7bff264c01a896188f1a7
Author: Shad Storhaug <[email protected]>
AuthorDate: Sun Oct 24 04:42:45 2021 +0700

    SWEEP: Lucene.Net: Use NumericUtils.SingleToSortableInt32() to compare 
floating point numbers (except in cases where we are testing for whole numbers).
---
 src/Lucene.Net/Search/BooleanQuery.cs                    |  4 +++-
 src/Lucene.Net/Search/DisjunctionMaxQuery.cs             |  5 +++--
 src/Lucene.Net/Search/FieldCache.cs                      |  3 ++-
 src/Lucene.Net/Search/HitQueue.cs                        |  7 ++++---
 src/Lucene.Net/Search/IndexSearcher.cs                   |  4 +++-
 src/Lucene.Net/Search/MatchAllDocsQuery.cs               |  4 +++-
 src/Lucene.Net/Search/MultiPhraseQuery.cs                |  8 +++++---
 src/Lucene.Net/Search/PhraseQuery.cs                     |  4 +++-
 src/Lucene.Net/Search/QueryRescorer.cs                   |  8 +++++---
 src/Lucene.Net/Search/ScoringRewrite.cs                  |  6 ++++--
 src/Lucene.Net/Search/Spans/FieldMaskingSpanQuery.cs     |  6 +++++-
 src/Lucene.Net/Search/Spans/SpanFirstQuery.cs            |  6 +++++-
 src/Lucene.Net/Search/Spans/SpanNearPayloadCheckQuery.cs |  8 +++++---
 src/Lucene.Net/Search/Spans/SpanNearQuery.cs             |  4 +++-
 src/Lucene.Net/Search/Spans/SpanOrQuery.cs               |  4 +++-
 src/Lucene.Net/Search/Spans/SpanPayloadCheckQuery.cs     |  8 +++++---
 src/Lucene.Net/Search/Spans/SpanPositionRangeQuery.cs    |  6 +++++-
 src/Lucene.Net/Search/TermQuery.cs                       |  5 ++++-
 src/Lucene.Net/Search/TopDocs.cs                         |  6 ++++--
 src/Lucene.Net/Search/TopFieldCollector.cs               | 15 ++++++++++-----
 src/Lucene.Net/Search/TopTermsRewrite.cs                 | 15 ++++++++++-----
 src/Lucene.Net/Util/Mutable/MutableValueDouble.cs        |  4 +++-
 src/Lucene.Net/Util/Mutable/MutableValueFloat.cs         |  6 ++++--
 src/Lucene.Net/Util/Packed/PackedInts.cs                 |  3 ++-
 24 files changed, 103 insertions(+), 46 deletions(-)

diff --git a/src/Lucene.Net/Search/BooleanQuery.cs 
b/src/Lucene.Net/Search/BooleanQuery.cs
index bd1c529..13c412e 100644
--- a/src/Lucene.Net/Search/BooleanQuery.cs
+++ b/src/Lucene.Net/Search/BooleanQuery.cs
@@ -1,5 +1,6 @@
 using J2N;
 using J2N.Collections.Generic.Extensions;
+using Lucene.Net.Util;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -681,7 +682,8 @@ namespace Lucene.Net.Search
                 return false;
             }
             BooleanQuery other = (BooleanQuery)o;
-            return this.Boost == other.Boost
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost)
                 && this.clauses.Equals(other.clauses)
                 && this.MinimumNumberShouldMatch == 
other.MinimumNumberShouldMatch
                 && this.disableCoord == other.disableCoord;
diff --git a/src/Lucene.Net/Search/DisjunctionMaxQuery.cs 
b/src/Lucene.Net/Search/DisjunctionMaxQuery.cs
index 35c8a4a..1d3358d 100644
--- a/src/Lucene.Net/Search/DisjunctionMaxQuery.cs
+++ b/src/Lucene.Net/Search/DisjunctionMaxQuery.cs
@@ -357,8 +357,9 @@ namespace Lucene.Net.Search
                 return false;
             }
             DisjunctionMaxQuery other = (DisjunctionMaxQuery)o;
-            return this.Boost == other.Boost 
-                && this.tieBreakerMultiplier == other.tieBreakerMultiplier 
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost)
+                && 
NumericUtils.SingleToSortableInt32(this.tieBreakerMultiplier) == 
NumericUtils.SingleToSortableInt32(other.tieBreakerMultiplier)
                 && this.disjuncts.Equals(other.disjuncts);
         }
 
diff --git a/src/Lucene.Net/Search/FieldCache.cs 
b/src/Lucene.Net/Search/FieldCache.cs
index daf1447..63812bc 100644
--- a/src/Lucene.Net/Search/FieldCache.cs
+++ b/src/Lucene.Net/Search/FieldCache.cs
@@ -1127,7 +1127,8 @@ namespace Lucene.Net.Search
             {
                 if (obj is AcceptableOverheadRatio other)
                 {
-                    return Value.Equals(other.Value);
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    return NumericUtils.SingleToSortableInt32(Value) == 
NumericUtils.SingleToSortableInt32(other.Value);
                 }
                 return false;
             }
diff --git a/src/Lucene.Net/Search/HitQueue.cs 
b/src/Lucene.Net/Search/HitQueue.cs
index 44d481a..0bc01eb 100644
--- a/src/Lucene.Net/Search/HitQueue.cs
+++ b/src/Lucene.Net/Search/HitQueue.cs
@@ -1,4 +1,4 @@
-namespace Lucene.Net.Search
+namespace Lucene.Net.Search
 {
     /*
      * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -76,13 +76,14 @@ namespace Lucene.Net.Search
 
         protected internal override sealed bool LessThan(ScoreDoc hitA, 
ScoreDoc hitB)
         {
-            if (hitA.Score == hitB.Score)
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            if (NumericUtils.SingleToSortableInt32(hitA.Score) == 
NumericUtils.SingleToSortableInt32(hitB.Score))
             {
                 return hitA.Doc > hitB.Doc;
             }
             else
             {
-                return hitA.Score < hitB.Score;
+                return NumericUtils.SingleToSortableInt32(hitA.Score) < 
NumericUtils.SingleToSortableInt32(hitB.Score);
             }
         }
     }
diff --git a/src/Lucene.Net/Search/IndexSearcher.cs 
b/src/Lucene.Net/Search/IndexSearcher.cs
index f76d991..712de33 100644
--- a/src/Lucene.Net/Search/IndexSearcher.cs
+++ b/src/Lucene.Net/Search/IndexSearcher.cs
@@ -1,6 +1,7 @@
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Support;
 using Lucene.Net.Support.Threading;
+using Lucene.Net.Util;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -818,7 +819,8 @@ namespace Lucene.Net.Search
                     }
 
                     // Carry over maxScore from sub:
-                    if (doMaxScore && docs.MaxScore > hq.maxScore)
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (doMaxScore && 
NumericUtils.SingleToSortableInt32(docs.MaxScore) > 
NumericUtils.SingleToSortableInt32(hq.maxScore))
                     {
                         hq.maxScore = docs.MaxScore;
                     }
diff --git a/src/Lucene.Net/Search/MatchAllDocsQuery.cs 
b/src/Lucene.Net/Search/MatchAllDocsQuery.cs
index f76beed..eda5d3e 100644
--- a/src/Lucene.Net/Search/MatchAllDocsQuery.cs
+++ b/src/Lucene.Net/Search/MatchAllDocsQuery.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Util;
 using System.Collections.Generic;
 using System.Text;
 
@@ -155,7 +156,8 @@ namespace Lucene.Net.Search
                 return false;
             }
             MatchAllDocsQuery other = (MatchAllDocsQuery)o;
-            return this.Boost == other.Boost;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/MultiPhraseQuery.cs 
b/src/Lucene.Net/Search/MultiPhraseQuery.cs
index 69f34d3..06e6048 100644
--- a/src/Lucene.Net/Search/MultiPhraseQuery.cs
+++ b/src/Lucene.Net/Search/MultiPhraseQuery.cs
@@ -26,6 +26,7 @@ namespace Lucene.Net.Search
      */
 
     using J2N.Collections.Generic.Extensions;
+    using Lucene.Net.Util;
     using System.Collections;
     using ArrayUtil = Lucene.Net.Util.ArrayUtil;
     using AtomicReader = Lucene.Net.Index.AtomicReader;
@@ -444,9 +445,10 @@ namespace Lucene.Net.Search
                 return false;
             }
             MultiPhraseQuery other = (MultiPhraseQuery)o;
-            return this.Boost == other.Boost 
-                && this.slop == other.slop 
-                && TermArraysEquals(this.termArrays, other.termArrays) 
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost)
+                && this.slop == other.slop
+                && TermArraysEquals(this.termArrays, other.termArrays)
                 && this.positions.Equals(other.positions);
         }
 
diff --git a/src/Lucene.Net/Search/PhraseQuery.cs 
b/src/Lucene.Net/Search/PhraseQuery.cs
index 4160b07..b598099 100644
--- a/src/Lucene.Net/Search/PhraseQuery.cs
+++ b/src/Lucene.Net/Search/PhraseQuery.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Index;
 using Lucene.Net.Support;
+using Lucene.Net.Util;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -504,7 +505,8 @@ namespace Lucene.Net.Search
                 return false;
             }
             PhraseQuery other = (PhraseQuery)o;
-            return (this.Boost == other.Boost) 
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return (NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost)) 
                 && (this.slop == other.slop) 
                 && this.terms.Equals(other.terms) 
                 && this.positions.Equals(other.positions);
diff --git a/src/Lucene.Net/Search/QueryRescorer.cs 
b/src/Lucene.Net/Search/QueryRescorer.cs
index 9dd70d0..df53424 100644
--- a/src/Lucene.Net/Search/QueryRescorer.cs
+++ b/src/Lucene.Net/Search/QueryRescorer.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Diagnostics;
+using Lucene.Net.Diagnostics;
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 
@@ -114,11 +115,12 @@ namespace Lucene.Net.Search
             Array.Sort(hits, Comparer<ScoreDoc>.Create((a, b) =>
             {
                 // Sort by score descending, then docID ascending:
-                if (a.Score > b.Score)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(a.Score) > 
NumericUtils.SingleToSortableInt32(b.Score))
                 {
                     return -1;
                 }
-                else if (a.Score < b.Score)
+                else if (NumericUtils.SingleToSortableInt32(a.Score) < 
NumericUtils.SingleToSortableInt32(b.Score))
                 {
                     return 1;
                 }
diff --git a/src/Lucene.Net/Search/ScoringRewrite.cs 
b/src/Lucene.Net/Search/ScoringRewrite.cs
index 67de649..1ed03ff 100644
--- a/src/Lucene.Net/Search/ScoringRewrite.cs
+++ b/src/Lucene.Net/Search/ScoringRewrite.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Diagnostics;
+using Lucene.Net.Diagnostics;
+using Lucene.Net.Util;
 using System;
 
 namespace Lucene.Net.Search
@@ -174,7 +175,8 @@ namespace Lucene.Net.Search
                     // duplicate term: update docFreq
                     int pos = (-e) - 1;
                     array.termState[pos].Register(state, m_readerContext.Ord, 
termsEnum.DocFreq, termsEnum.TotalTermFreq);
-                    if (Debugging.AssertsEnabled) 
Debugging.Assert(array.boost[pos] == boostAtt.Boost, "boost should be equal in 
all segment TermsEnums");
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (Debugging.AssertsEnabled) 
Debugging.Assert(NumericUtils.SingleToSortableInt32(array.boost[pos]) == 
NumericUtils.SingleToSortableInt32(boostAtt.Boost), "boost should be equal in 
all segment TermsEnums");
                 }
                 else
                 {
diff --git a/src/Lucene.Net/Search/Spans/FieldMaskingSpanQuery.cs 
b/src/Lucene.Net/Search/Spans/FieldMaskingSpanQuery.cs
index 8a16895..5a1782a 100644
--- a/src/Lucene.Net/Search/Spans/FieldMaskingSpanQuery.cs
+++ b/src/Lucene.Net/Search/Spans/FieldMaskingSpanQuery.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -144,7 +145,10 @@ namespace Lucene.Net.Search.Spans
                 return false;
             }
             FieldMaskingSpanQuery other = (FieldMaskingSpanQuery)o;
-            return (this.Field.Equals(other.Field, StringComparison.Ordinal) 
&& (this.Boost == other.Boost) && this.MaskedQuery.Equals(other.MaskedQuery));
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return (this.Field.Equals(other.Field, StringComparison.Ordinal)
+                && (NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost))
+                && this.MaskedQuery.Equals(other.MaskedQuery));
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs 
b/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs
index 57d6964..fd393f5 100644
--- a/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs
+++ b/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs
@@ -1,5 +1,6 @@
 using J2N.Numerics;
 using Lucene.Net.Diagnostics;
+using Lucene.Net.Util;
 using System.Text;
 
 namespace Lucene.Net.Search.Spans
@@ -88,7 +89,10 @@ namespace Lucene.Net.Search.Spans
             }
 
             SpanFirstQuery other = (SpanFirstQuery)o;
-            return this.m_end == other.m_end && 
this.m_match.Equals(other.m_match) && this.Boost == other.Boost;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return this.m_end == other.m_end
+                && this.m_match.Equals(other.m_match)
+                && NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/Spans/SpanNearPayloadCheckQuery.cs 
b/src/Lucene.Net/Search/Spans/SpanNearPayloadCheckQuery.cs
index 73a8f49..0839c6c 100644
--- a/src/Lucene.Net/Search/Spans/SpanNearPayloadCheckQuery.cs
+++ b/src/Lucene.Net/Search/Spans/SpanNearPayloadCheckQuery.cs
@@ -1,5 +1,6 @@
 using J2N.Numerics;
 using Lucene.Net.Support;
+using Lucene.Net.Util;
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
@@ -130,9 +131,10 @@ namespace Lucene.Net.Search.Spans
             }
 
             // LUCENENET NOTE: Need to use the structural equality comparer to 
compare equality of all contained values
-            return payloadEqualityComparer.Equals(this.m_payloadToMatch, 
other.m_payloadToMatch) 
-                && this.m_match.Equals(other.m_match) 
-                && this.Boost == other.Boost;
+            return payloadEqualityComparer.Equals(this.m_payloadToMatch, 
other.m_payloadToMatch)
+                && this.m_match.Equals(other.m_match)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                && NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/Spans/SpanNearQuery.cs 
b/src/Lucene.Net/Search/Spans/SpanNearQuery.cs
index 4d419f8..21a058e 100644
--- a/src/Lucene.Net/Search/Spans/SpanNearQuery.cs
+++ b/src/Lucene.Net/Search/Spans/SpanNearQuery.cs
@@ -1,5 +1,6 @@
 using J2N.Collections.Generic.Extensions;
 using J2N.Numerics;
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -209,7 +210,8 @@ namespace Lucene.Net.Search.Spans
                 return false;
             }
 
-            return Boost == spanNearQuery.Boost;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(Boost) == 
NumericUtils.SingleToSortableInt32(spanNearQuery.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/Spans/SpanOrQuery.cs 
b/src/Lucene.Net/Search/Spans/SpanOrQuery.cs
index 484e4cf..2d9e297 100644
--- a/src/Lucene.Net/Search/Spans/SpanOrQuery.cs
+++ b/src/Lucene.Net/Search/Spans/SpanOrQuery.cs
@@ -1,5 +1,6 @@
 using J2N.Collections.Generic.Extensions;
 using J2N.Numerics;
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -163,7 +164,8 @@ namespace Lucene.Net.Search.Spans
                 return false;
             }
 
-            return Boost == that.Boost;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(Boost) == 
NumericUtils.SingleToSortableInt32(that.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/Spans/SpanPayloadCheckQuery.cs 
b/src/Lucene.Net/Search/Spans/SpanPayloadCheckQuery.cs
index 9fb0dc2..7bd4b45 100644
--- a/src/Lucene.Net/Search/Spans/SpanPayloadCheckQuery.cs
+++ b/src/Lucene.Net/Search/Spans/SpanPayloadCheckQuery.cs
@@ -4,6 +4,7 @@ using System;
 using System.Text;
 using System.Collections;
 using J2N.Numerics;
+using Lucene.Net.Util;
 
 namespace Lucene.Net.Search.Spans
 {
@@ -134,9 +135,10 @@ namespace Lucene.Net.Search.Spans
 
             SpanPayloadCheckQuery other = (SpanPayloadCheckQuery)o;
             // LUCENENET NOTE: Need to use the structural equality comparer to 
compare equality of all contained values
-            return payloadEqualityComparer.Equals(this.m_payloadToMatch, 
other.m_payloadToMatch) 
-                && this.m_match.Equals(other.m_match) 
-                && this.Boost == other.Boost;
+            return payloadEqualityComparer.Equals(this.m_payloadToMatch, 
other.m_payloadToMatch)
+                && this.m_match.Equals(other.m_match)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                && NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/Spans/SpanPositionRangeQuery.cs 
b/src/Lucene.Net/Search/Spans/SpanPositionRangeQuery.cs
index b37b948..1ae24c2 100644
--- a/src/Lucene.Net/Search/Spans/SpanPositionRangeQuery.cs
+++ b/src/Lucene.Net/Search/Spans/SpanPositionRangeQuery.cs
@@ -1,5 +1,6 @@
 using J2N.Numerics;
 using Lucene.Net.Diagnostics;
+using Lucene.Net.Util;
 using System.Text;
 
 namespace Lucene.Net.Search.Spans
@@ -93,7 +94,10 @@ namespace Lucene.Net.Search.Spans
             }
 
             SpanPositionRangeQuery other = (SpanPositionRangeQuery)o;
-            return this.m_end == other.m_end && this.m_start == other.m_start 
&& this.m_match.Equals(other.m_match) && this.Boost == other.Boost;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return this.m_end == other.m_end
+                && this.m_start == other.m_start
+                && this.m_match.Equals(other.m_match) && 
NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost);
         }
 
         public override int GetHashCode()
diff --git a/src/Lucene.Net/Search/TermQuery.cs 
b/src/Lucene.Net/Search/TermQuery.cs
index e9bb646..f3469d4 100644
--- a/src/Lucene.Net/Search/TermQuery.cs
+++ b/src/Lucene.Net/Search/TermQuery.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Diagnostics;
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -233,7 +234,9 @@ namespace Lucene.Net.Search
                 return false;
             }
             TermQuery other = (TermQuery)o;
-            return (this.Boost == other.Boost) && this.term.Equals(other.term);
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return (NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost))
+                && this.term.Equals(other.term);
         }
 
         /// <summary>
diff --git a/src/Lucene.Net/Search/TopDocs.cs b/src/Lucene.Net/Search/TopDocs.cs
index c142bad..38a5e76 100644
--- a/src/Lucene.Net/Search/TopDocs.cs
+++ b/src/Lucene.Net/Search/TopDocs.cs
@@ -1,5 +1,6 @@
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Support;
+using Lucene.Net.Util;
 using System;
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.CompilerServices;
@@ -111,11 +112,12 @@ namespace Lucene.Net.Search
                 float firstScore = 
shardHits[first.ShardIndex][first.HitIndex].Score;
                 float secondScore = 
shardHits[second.ShardIndex][second.HitIndex].Score;
 
-                if (firstScore < secondScore)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(firstScore) < 
NumericUtils.SingleToSortableInt32(secondScore))
                 {
                     return false;
                 }
-                else if (firstScore > secondScore)
+                else if (NumericUtils.SingleToSortableInt32(firstScore) > 
NumericUtils.SingleToSortableInt32(secondScore))
                 {
                     return true;
                 }
diff --git a/src/Lucene.Net/Search/TopFieldCollector.cs 
b/src/Lucene.Net/Search/TopFieldCollector.cs
index df83744..8e94e0e 100644
--- a/src/Lucene.Net/Search/TopFieldCollector.cs
+++ b/src/Lucene.Net/Search/TopFieldCollector.cs
@@ -299,7 +299,8 @@ namespace Lucene.Net.Search
             public override void Collect(int doc)
             {
                 float score = scorer.GetScore();
-                if (score > maxScore)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(score) > 
NumericUtils.SingleToSortableInt32(maxScore))
                 {
                     maxScore = score;
                 }
@@ -355,7 +356,8 @@ namespace Lucene.Net.Search
             public override void Collect(int doc)
             {
                 float score = scorer.GetScore();
-                if (score > maxScore)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(score) > 
NumericUtils.SingleToSortableInt32(maxScore))
                 {
                     maxScore = score;
                 }
@@ -600,7 +602,8 @@ namespace Lucene.Net.Search
             public override void Collect(int doc)
             {
                 float score = scorer.GetScore();
-                if (score > maxScore)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(score) > 
NumericUtils.SingleToSortableInt32(maxScore))
                 {
                     maxScore = score;
                 }
@@ -685,7 +688,8 @@ namespace Lucene.Net.Search
             public override void Collect(int doc)
             {
                 float score = scorer.GetScore();
-                if (score > maxScore)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(score) > 
NumericUtils.SingleToSortableInt32(maxScore))
                 {
                     maxScore = score;
                 }
@@ -990,7 +994,8 @@ namespace Lucene.Net.Search
                 if (trackMaxScore)
                 {
                     score = scorer.GetScore();
-                    if (score > maxScore)
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (NumericUtils.SingleToSortableInt32(score) > 
NumericUtils.SingleToSortableInt32(maxScore))
                     {
                         maxScore = score;
                     }
diff --git a/src/Lucene.Net/Search/TopTermsRewrite.cs 
b/src/Lucene.Net/Search/TopTermsRewrite.cs
index 08e4a50..7d489db 100644
--- a/src/Lucene.Net/Search/TopTermsRewrite.cs
+++ b/src/Lucene.Net/Search/TopTermsRewrite.cs
@@ -1,5 +1,6 @@
-using J2N.Collections.Generic.Extensions;
+using J2N.Collections.Generic.Extensions;
 using Lucene.Net.Diagnostics;
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 using JCG = J2N.Collections.Generic;
@@ -161,11 +162,13 @@ namespace Lucene.Net.Search
                 if (stQueue.Count == maxSize)
                 {
                     ScoreTerm t = stQueue.Peek();
-                    if (boost < t.Boost)
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (NumericUtils.SingleToSortableInt32(boost) < 
NumericUtils.SingleToSortableInt32(t.Boost))
                     {
                         return true;
                     }
-                    if (boost == t.Boost && termComp.Compare(bytes, t.Bytes) > 
0)
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (NumericUtils.SingleToSortableInt32(boost) == 
NumericUtils.SingleToSortableInt32(t.Boost) && termComp.Compare(bytes, t.Bytes) 
> 0)
                     {
                         return true;
                     }
@@ -175,7 +178,8 @@ namespace Lucene.Net.Search
                 if (visitedTerms.TryGetValue(bytes, out ScoreTerm t2))
                 {
                     // if the term is already in the PQ, only update docFreq 
of term in PQ
-                    if (Debugging.AssertsEnabled) Debugging.Assert(t2.Boost == 
boost, "boost should be equal in all segment TermsEnums");
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (Debugging.AssertsEnabled) 
Debugging.Assert(NumericUtils.SingleToSortableInt32(t2.Boost) == 
NumericUtils.SingleToSortableInt32(boost), "boost should be equal in all 
segment TermsEnums");
                     t2.TermState.Register(state, m_readerContext.Ord, 
termsEnum.DocFreq, termsEnum.TotalTermFreq);
                 }
                 else
@@ -264,7 +268,8 @@ namespace Lucene.Net.Search
 
             public int CompareTo(ScoreTerm other)
             {
-                if (this.Boost == other.Boost)
+                // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                if (NumericUtils.SingleToSortableInt32(this.Boost) == 
NumericUtils.SingleToSortableInt32(other.Boost))
                 {
                     return TermComp.Compare(other.Bytes, this.Bytes);
                 }
diff --git a/src/Lucene.Net/Util/Mutable/MutableValueDouble.cs 
b/src/Lucene.Net/Util/Mutable/MutableValueDouble.cs
index 2490cc8..c846f1d 100644
--- a/src/Lucene.Net/Util/Mutable/MutableValueDouble.cs
+++ b/src/Lucene.Net/Util/Mutable/MutableValueDouble.cs
@@ -56,7 +56,9 @@ namespace Lucene.Net.Util.Mutable
         public override bool EqualsSameType(object other)
         {
             MutableValueDouble b = (MutableValueDouble)other;
-            return Value == b.Value && Exists == b.Exists;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.DoubleToSortableInt64(Value) == 
NumericUtils.DoubleToSortableInt64(b.Value)
+                && Exists == b.Exists;
         }
 
         public override int CompareSameType(object other)
diff --git a/src/Lucene.Net/Util/Mutable/MutableValueFloat.cs 
b/src/Lucene.Net/Util/Mutable/MutableValueFloat.cs
index 59ff786..de6d8cd 100644
--- a/src/Lucene.Net/Util/Mutable/MutableValueFloat.cs
+++ b/src/Lucene.Net/Util/Mutable/MutableValueFloat.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
 
 namespace Lucene.Net.Util.Mutable
 {
@@ -56,7 +56,9 @@ namespace Lucene.Net.Util.Mutable
         public override bool EqualsSameType(object other)
         {
             MutableValueSingle b = (MutableValueSingle)other;
-            return Value == b.Value && Exists == b.Exists;
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            return NumericUtils.SingleToSortableInt32(Value) == 
NumericUtils.SingleToSortableInt32(b.Value)
+                && Exists == b.Exists;
         }
 
         public override int CompareSameType(object other)
diff --git a/src/Lucene.Net/Util/Packed/PackedInts.cs 
b/src/Lucene.Net/Util/Packed/PackedInts.cs
index 800c599..903d255 100644
--- a/src/Lucene.Net/Util/Packed/PackedInts.cs
+++ b/src/Lucene.Net/Util/Packed/PackedInts.cs
@@ -343,7 +343,8 @@ namespace Lucene.Net.Util.Packed
                     {
                         float overhead = 
Format.PACKED_SINGLE_BLOCK.OverheadPerValue(bpv);
                         float acceptableOverhead = acceptableOverheadPerValue 
+ bitsPerValue - bpv;
-                        if (overhead <= acceptableOverhead)
+                        // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                        if (NumericUtils.SingleToSortableInt32(overhead) <= 
NumericUtils.SingleToSortableInt32(acceptableOverhead))
                         {
                             actualBitsPerValue = bpv;
                             format = Format.PACKED_SINGLE_BLOCK;

Reply via email to