Skip to content

Instantly share code, notes, and snippets.

@josejuan
Created June 17, 2012 00:00
Show Gist options
  • Save josejuan/2942896 to your computer and use it in GitHub Desktop.
Save josejuan/2942896 to your computer and use it in GitHub Desktop.
haszero
// http://graphics.stanford.edu/~seander/bithacks.html
#define haszero(v) (((v) - 0x01010101UL) & ~(v) & 0x80808080UL)
// en 4 operaciones indica si un byte de entre todos es 0
// para 64 bits será, lógicamente
#define haszero(v) (((v) - 0x0101010101010101UL) & ~(v) & 0x8080808080808080UL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment