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

Negative numbers cannot be powers of two.



That's definitely true- but say you want to check for (+/-2)^n, then you would have to deal with negative numbers.

If you go by the Two's complement representation, then for a negative number say (-8), because of sign extention, a check for x&(x-1) would fail.




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

Search: