classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: fix Float/DoubleBuffer.compareTo in the presence


From: Anthony Green
Subject: Re: [cp-patches] Patch: fix Float/DoubleBuffer.compareTo in the presence of NaN
Date: Tue, 06 Dec 2005 18:50:45 -0800

On Tue, 2005-12-06 at 11:12 -0700, Tom Tromey wrote:
> >>>>> "Anthony" == Anthony Green <address@hidden> writes:
> 
> Anthony> This patch makes sure FloatBuffer and DoubleBuffer objects compare
> Anthony> properly when they contain NaN values.  I've already checked in Mauve
> Anthony> tests cases.  Ok to commit?
> 
> Does it do the right thing if a is NaN and b is not?  Or vice versa?
> If so, this is ok.

Yes, definitely.  Although I have what is probably an even simpler patch
now.  I'll commit the following later tomorrow unless there are
objections.


Index: java/nio/FloatBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/FloatBuffer.java,v
retrieving revision 1.20
diff -u -r1.20 FloatBuffer.java
--- java/nio/FloatBuffer.java   2 Jul 2005 20:32:39 -0000       1.20
+++ java/nio/FloatBuffer.java   7 Dec 2005 02:46:34 -0000
@@ -303,8 +303,12 @@
           
        if (a < b)
          return -1;
-          
-       return 1;
+
+       if (a > b)
+         return 1;
+
+       // Otherwise a and b must both be NaN and we can continue
+       // looping.
       }
       
     return remaining() - other.remaining();


(and similarly for DoubleBuffer.java)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]