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

With ~~foo you will always get an integer that fits inside a 32-bit integer range... regardless of the input... invalid numbers will be 0. Whereas with a +foo you may get NaN (for an invalid decimal input).

Part of this is because bitwise operations will convert whatever the input value is to a 32-bit integer value before performing the operation, and not fail (invalid input becomes 0 opposed to NaN).



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

Search: