Skip to content

Instantly share code, notes, and snippets.

@arms22
Created July 2, 2017 23:55
Show Gist options
  • Save arms22/f3797f94632d8cbd4544503c5b6c6dc2 to your computer and use it in GitHub Desktop.
Save arms22/f3797f94632d8cbd4544503c5b6c6dc2 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(void){
unsigned long in = 0x00000003;
unsigned long out;
out = in;
out = ((out & 0x0000ff00) << 8) | (out & 0x000000ff);
out = ((out & 0x00f0f0f0) << 4) | (out & 0x000f0f0f);
out = ((out & 0x0ccccccc) << 2) | (out & 0x03333333);
out = ((out & 0xaaaaaaaa) << 1) | (out & 0x55555555);
printf("in %lx out %lx\n",in, out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment