Hi Thomas,
 

> Changing ValueFloat.get and ValueDouble.get should be enough, but I didn't 
> test it yet.
>

You are spot on!
In fact, you had dedicated code to try to handle -0.0, and removing it 
solved all the issues ("ABS(x)" works, and no more negative zeros!). Now 
the SELECT test case I indicated returns TRUE for all cases.

I attach a patch for those 2 classes.

I also noticed something related to -0.0 in "TestValueMemory.testCompare()" 
but it is for BigDecimal. I did not change anything there, but I wonder 
whether BigDecimal also has strange behaviors related to signed zeros.

In any case, please let me know when a stable build contains the fix.
 

> By the way, I will be on vacation for the next two weeks.
>

Enjoy your holidays, and thank you very much for your help! :)

Cheers,
-Christopher

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
Index: org/h2/value/ValueDouble.java
===================================================================
--- org/h2/value/ValueDouble.java       (revision 6122)
+++ org/h2/value/ValueDouble.java       (working copy)
@@ -93,11 +93,7 @@
         } else if (Double.isNaN(value)) {
             return "SQRT(-1)";
         }
-        String s = getString();
-        if (s.equals("-0.0")) {
-            return "-CAST(0 AS DOUBLE)";
-        }
-        return s;
+        return getString();
     }
 
     @Override
@@ -163,11 +159,8 @@
         if (d == 1.0) {
             return ONE;
         } else if (d == 0.0) {
-            // unfortunately, -0.0 == 0.0, but we don't want to return
-            // 0.0 in this case
-            if (Double.doubleToLongBits(d) == ZERO_BITS) {
-                return ZERO;
-            }
+            // -0.0 == 0.0, and we want to return 0.0 for both
+            return ZERO;
         } else if (Double.isNaN(d)) {
             return NAN;
         }
Index: org/h2/value/ValueFloat.java
===================================================================
--- org/h2/value/ValueFloat.java        (revision 6122)
+++ org/h2/value/ValueFloat.java        (working copy)
@@ -93,11 +93,7 @@
             // NaN
             return "SQRT(-1)";
         }
-        String s = getString();
-        if (s.equals("-0.0")) {
-            return "-CAST(0 AS REAL)";
-        }
-        return s;
+        return getString();
     }
 
     @Override
@@ -163,11 +159,8 @@
         if (d == 1.0F) {
             return ONE;
         } else if (d == 0.0F) {
-            // unfortunately, -0.0 == 0.0, but we don't want to return
-            // 0.0 in this case
-            if (Float.floatToIntBits(d) == ZERO_BITS) {
-                return ZERO;
-            }
+            // -0.0 == 0.0, and we want to return 0.0 for both
+            return ZERO;
         }
         return (ValueFloat) Value.cache(new ValueFloat(d));
     }

Reply via email to