Hi all,

We have a problem with zeros of DOUBLE type, as well as negative zeros. We 
are using the latest stable H2 1.3.176.

The odd behaviors we found are:
-0.0 is allowed and not turned into 0.0.
-0.0 is not zero.
ABS(-0.0) is zero.
ABS(0.0) is negative zero.
To test zero, we have to test (x = ZERO() OR ABS(x) = ZERO()).

We push DOUBLE data programmatically to an H2 database, then users write 
queries to extract data. The ABS function turning zeros to negative zeros 
creates all sorts of wrong behaviors. Moreover, I don't think that pushing 
a negative zero is legitimate from an SQL point of view (SQL Server used to 
have this issue which they fixed IIRC), and negative zeros should be saved 
as normal zeros.

This is the test case:
SELECT
ABS(CAST('0.0' AS DOUBLE)),
ABS(CAST('-0.0' AS DOUBLE)),
CAST('-0.0' AS DOUBLE),
CAST('-0.0' AS DOUBLE) = ZERO(),
CAST('0.0' AS DOUBLE) = ZERO(),
ABS(CAST('0.0' AS DOUBLE)) = ZERO(),
ABS(CAST('-0.0' AS DOUBLE)) = ZERO()

Please let me know what you think and do tell me if we are doing something 
wrong.
-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.

Reply via email to