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

  ((x & (INT_MAX / 2)) * 2) / 2

?


My version works up to x = INT_MAX and your version still fails for negative ints, so I don't see the benefit of restricting the range. Getting closer :)




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

Search: