Hi,
I'm not sure what we should do here.
I think we have two options: support -0.0 (as we do now), or completely
remove support for it. I don't see a way that we can support it on some
places, but not support it in other places.
Supporting -0.0 (as we do now), means it is not the same as 0.0. In SQL,
unlike in Java, there is only one comparison operation, that is, "equals"
implies "==" and vice versa. In Java, there is "equals" and there is "==",
which have a different behavior for 0.0 and -0.0:
System.out.println(Double.valueOf(-0.0d).equals(Double.valueOf(0.0d)));
-> false
System.out.println((-0.0d == 0.0d)); -> true
If we support -0.0 but say it is equal to 0.0 in H2, then a unique index on
a Double would have a strange situation where we either allow -0.0 or 0.0
but not both. A non-unique index could have a mix of -0.0 and 0.0, and they
would be ordered randomly (because they are equal but not the same).
If we remove support for -0.0, then any operation that returns -0.0 would
return 0.0, and -0.0 as a value (for a user defined function, via prepared
statement, and so on) would be converted to 0.0. It looks like this is what
other databases do. But I'm not a fan of that.
I tend to think that the current solution, which is to support -0.0, is
fine.
Regards,
Thomas
On Saturday, June 6, 2015, Noel Grandin <[email protected]> wrote:
> On Fri, Jun 5, 2015 at 6:08 PM, Thomas Mueller
> <[email protected]> wrote:
> > Well it depends on what you think is "proper"... I would probably avoid
> > using negative zeroes. I don't know why they are even supported in Java.
> >
>
> Java uses the IEEE spec for floating point numbers, which for reasons
> beyond my understanding, has a concept of positive and negative zero.
>
> --
> 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.
>
--
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.