[
https://issues.apache.org/jira/browse/GROOVY-3309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15457495#comment-15457495
]
John Wagenleitner commented on GROOVY-3309:
-------------------------------------------
Just want to point out that the 3rd case that was reported to fail will pass if
a literal double is used instead of just 0.
{code}
assert !(Double.NaN > 0d)
double d; // just to show the uninitialized value works (0.0d)
assert !(Double.NaN > d)
{code}
I think for the NaN to NaN comparison not only does {{Double#compareTo}} but
also {{Double#equals}} also returns true. So think the following are all
reasonable:
{code}
Double d1 = Double.NaN
Double d2 = Double.NaN
assert d1 == d2
assert !d1.is(d2)
assert !d2.is(d1)
{code}
Since {{==}} usually is {{compareTo}} or {{equals}}, it seems that to do the
same route with primitives the choice would be to use {{is}}.
> comparisons with NaN should always return false
> -----------------------------------------------
>
> Key: GROOVY-3309
> URL: https://issues.apache.org/jira/browse/GROOVY-3309
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 1.5.7, 1.6-rc-2
> Environment: os x, jse 5 and 6
> Reporter: Andy Fyfe
> Fix For: 3.0
>
>
> The following assertions should all pass; the third fails.
> {code}
> assert !(Double.NaN == 0)
> assert !(Double.NaN < 0)
> assert !(Double.NaN > 0)
> {code}
> A NaN should also not equal a NaN.
> {code}assert Double.NaN != Double.NaN{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)