Hi Noel, 

Java uses the IEEE spec for floating point numbers, which for reasons 
> beyond my understanding, has a concept of positive and negative zero. 
>

Actually, in Java, this concept of a negative zero is not a problem. Let me 
explain: there are 2 cases.
Note that I will talk about Double, but it is also applicable to Float.

1. Primitive double, arithmetic.

When manipulating doubles for all sorts of computations, negative zeros 
behave exactly like positive zeros. The only difference is that a negative 
zero conveys an additional meaning, which is that a negative value 
approximates zero, thus being able to produce negative infinity rather than 
positive infinity with certain operations.

2. Object Double, identity.

Double objects on the other hand, are not used for arithmetic operations. 
The only sensible reason to wrap a primitive double to a Double object is 
to use it in signatures that accept Objects, or for its identity, thus 
having negative zero being different than positive zero and NaN being equal 
to NaN.

Now, H2 claims to map DOUBLE type to a Double object, which is fine for 
internal storage, but operations must use the logic of a primitive Double. 
The only exception I would add is NaN to be equal to NaN, because SQL does 
not have an IS NAN operator, and already has similar logic with NULL. This 
would make performing arithmetic operations on DOUBLE columns possible.

Please let me know what you think,
-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