Hacker News new | ask | show | jobs
by gwilliams 2325 days ago
boolean checkExactlyOneBitSet(int num) {

return (num & (num - 1)) == 0;

}

That looks like it'll fail when num == 0. I think it should be:

  return num && ((num & (num - 1)) == 0);
1 comments

maybe posting a github issue would be helpful