Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Common 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.


There'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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: