Skip to content

Instantly share code, notes, and snippets.

@mythagel
Created March 22, 2013 05:40
Show Gist options
  • Save mythagel/5219207 to your computer and use it in GitHub Desktop.
Save mythagel/5219207 to your computer and use it in GitHub Desktop.
bittest.cpp
#include <iostream>
#include <cstdint>
#include <cstring>
int main()
{
uint64_t hi;
uint64_t lo;
if(hi & 0x8000000000000000ULL)
hi = ~hi;
int off = ffsll(hi);
hi <<= off;
hi = ~hi;
int pattern = ffsll(hi);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment