C++ guarantees that 0.0/0.0
is NaN
, so this is the easiest way to express it.
Remember that NaN != NaN
, so (0.0/0.0) == (0.0/0.0)
is actually false. To test for NaN-ness, if you don't have a library is_nan
somewhere, just check for x != x
for some candidate double x
.