Hacker News new | past | comments | ask | show | jobs | submit login

But would you be sure that the implementation isOdd you are using is safe? To be sure you end up needing to try a few values, or to read the implementation, at which point you might as well write isOdd = n => n % 1.

That does not hold true for more complex stuff, but to test whether a number is odd, come on.

You'll test your code if it works anyway and if your odd test is wrong it will show.

But yes, you need to make sure on how '%' works in your programming language especially on negative numbers (and on non integers) because that can differ.

If you are testing whether a number is odd and that number can be negative, you'll probably think about it anyway.

That's a trap you should encounter once and then you are good.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: