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


The following commit(s) were added to refs/heads/master by this push:
     new fa40d1a  BUG: Lucene.Net.Expressions.ScoreFunctionValues: Changed to 
explicit cast to (float) to prevent JIT from losing precision when assigning 
the value to double. Fixes 
Lucene.Net.Expressions.TestExpressionSorts::TestQueries().
fa40d1a is described below

commit fa40d1a44c89a27c02e4ef4ef68ba9ef8d4eff81
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Nov 23 14:47:10 2021 +0700

    BUG: Lucene.Net.Expressions.ScoreFunctionValues: Changed to explicit cast 
to (float) to prevent JIT from losing precision when assigning the value to 
double. Fixes Lucene.Net.Expressions.TestExpressionSorts::TestQueries().
---
 src/Lucene.Net.Expressions/ScoreFunctionValues.cs | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/Lucene.Net.Expressions/ScoreFunctionValues.cs 
b/src/Lucene.Net.Expressions/ScoreFunctionValues.cs
index 942b550..b4f8f08 100644
--- a/src/Lucene.Net.Expressions/ScoreFunctionValues.cs
+++ b/src/Lucene.Net.Expressions/ScoreFunctionValues.cs
@@ -45,12 +45,8 @@ namespace Lucene.Net.Expressions
             {
                 if (Debugging.AssertsEnabled) Debugging.Assert(document == 
scorer.DocID);
 
-#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
-                return scorer.GetScore();
-#else
-                // LUCENENET specific: The intermediate cast to decimal is 
required here to prevent us from losing precision on x86 .NET Framework with 
optimizations enabled
-                return (double)(decimal)scorer.GetScore();
-#endif
+                // LUCENENET specific: The explicit cast to float is required 
here to prevent us from losing precision on x86 .NET Framework with 
optimizations enabled
+                return (float)scorer.GetScore();
             }
             catch (Exception exception) when (exception.IsIOException())
             {

Reply via email to