I googled the answer. They said use Double.compare(). It does not work.
Double.compare(-0d, 0d) < 0
This gives me false. Should be true.
Math.signum() does not work with -0d. The document says it will give me back -0d.
On the other hand, if I have a formula that calculate the value to be -zero, compare gives me a different answer.
def xyz = -0d
Double.compare(xyz, 0d) < 0 will give me false
def xyz = 0d * -1d
Double.compare(xyz, 0d) < 0 will give me true
Is this a bug in Grails?
Why do you expect comparing -0d
with 0d
to be not equal?
Double.compare(-0d, 0d) < 0// returns false
cause
Double.compare(-0d, 0d) == 0 //returns true