4 ms·
What about nan? The test '!(x < 0 || x > 1)' will say yes, while 'x >= 0 && x <= 1' will say no. Or -0 for that matter.
by santaclaus 10y ago
What about nan? The test '!(x < 0 || x > 1)' will say yes, while 'x >= 0 && x <= 1' will say no.
Or -0 for that matter.
- amelius 10y agoCommon sense approach: like the name says, NaN is not a number. The question was about floating point numbers, not floating point values. So I suppose we shouldn't count NaN. Further, -0 (an arbitrarily small number less than 0) doesn't logically fall in the range [0, 1], so it is excluded.
- mark-r 10y agoThere's no need to exclude -0.0, since mathematically and by all tests available to the floating point unit it's equal to +0.0.