Hi George, If you use my original example without adding "diff-line", it will output true in release mode and false in debug.
But the problem related with Lucene is (I suppose) that 0.1(or 0.01) does not have an exact binary representation (like 1/3 in decimal). (for ex, Running the example for 0.5 gives always true as expected) Adding and then subtracting 1 from a float may result, therefore, in a slightly different number as in your case. So, expecting an exact match when dealing with "float" is very optimistic. That is the reason for using the SCORE_COMP_THRESH value. DIGY -----Original Message----- From: George Aroush [mailto:[EMAIL PROTECTED] Sent: Thursday, September 13, 2007 6:11 PM To: [email protected] Subject: RE: [jira] Commented: (LUCENENET-95) Nunite test for Search.TestDisjunctionMaxQuery.TestBooleanOptionalWithTiebreaker In my case, optimized or debugged, I always get 'false' and -2.235174E-08 for "Console.WriteLine("Diff: " + (f2-fn))". I really find it hard to believe that the output will different for optimized and debug code for such a case. This is such an easy case to slip past QA. -- George > -----Original Message----- > From: Granroth, Neal V. [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 13, 2007 10:38 AM > To: [email protected] > Subject: RE: [jira] Commented: (LUCENENET-95) Nunite test for > Search.TestDisjunctionMaxQuery.TestBooleanOptionalWithTiebreaker > > A slight alteration to your example makes it work the same in > both release and debug > > static void Main() > { > float f2 = 0.1f; > float fn = f2; > > fn += 1; > fn -= 1; > > Console.WriteLine("Diff: " + (f2-fn)); > > Console.WriteLine("f2==fn -> " + (f2==fn).ToString()); > fn = f2; > > } > > It seems that there is a problem with the optimization that > occurs in release; you have actually use the altered value > "fn" for the equality test to work properly. > > -- Neal > > -----Original Message----- > From: Digy (JIRA) [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 13, 2007 7:34 AM > To: [email protected] > Subject: [jira] Commented: (LUCENENET-95) Nunite test for > Search.TestDisjunctionMaxQuery.TestBooleanOptionalWithTiebreaker > > > [ > https://issues.apache.org/jira/browse/LUCENENET-95?page=com.at lassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12527087 ] > > Digy commented on LUCENENET-95: > ------------------------------- > > I prepared a sample case: > > > static void Main() > { > float f2 = 0.1f; > float fn = f2; > > fn += 1; > fn -= 1; > > Console.WriteLine("f2==fn -> " + (f2==fn).ToString()); > fn = f2; > } > > > > it outputs true or false depending on the build type(release or debug) > > > Since all numbers can not be stored exactly when using > floating point representation, > (http://www.yoda.arachsys.com/csharp/floatingpoint.html) > it is safer to apply the SCORE_COMP_THRESH patch > > DIGY > >
