Hi DIGY, With or without the diff-line I get false in debug and release mode. In addition, I tried your test code (as well as the NUnit test) on two other machine (this time with .NET 2.0.50727 on both machines) -- one machine is Intel Pentium 4 3.2GHz and the other is Intel Xeon 2.4GHz (2 CPUs). In all cases and combinations, the NUnit test passed and I got 'false' from your test case (again with or without the diff-line and in both release and debug mode.
I understand the issue with float (adding and then subtracting, etc.) What I don't understand is why you are seeing different results then what I'm seeing. The inconsistency of the float should be consistence from machine to machine or .NET version -- which I'm observing in the tests that I have run. This said, this is a NUnit issue which seems to be affecting you. I believe it is safe to close this issue. Regards, -- George > -----Original Message----- > From: DIGY [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 13, 2007 12:30 PM > To: [email protected] > Subject: RE: [jira] Commented: (LUCENENET-95) Nunite test for > Search.TestDisjunctionMaxQuery.TestBooleanOptionalWithTiebreaker > > 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#act > ion_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 > > > > >
