Reputation: 2502
I've been facing a problem with NaN causing exceptions in a project I'm working on. I was wondering if somebody could provide a list of all of the possible ways an NaN might surface in Java, so I could know all of the possible things to look for while tracking it down.
Upvotes: 0
Views: 285
Reputation: 6652
Source: https://stackoverflow.com/a/2887161/546060
NaN
is triggered by the following occurrences:
Upvotes: 3
Reputation: 1878
Here are some:
Double.NaN + Double.NaN -> NaN
Float.NaN + 2.0 -> NaN
Float.NaN * 3.0 -> NaN
(0.0 / 0.0) * Float.POSITIVE_INFINITY -> NaN
Math.abs(0.0 / 0.0) -> NaN
Taken from here.
Upvotes: 0