Created
June 15, 2016 16:23
-
-
Save sideb0ard/de88bd2cf0da86297912589baf0364aa to your computer and use it in GitHub Desktop.
bitwise reverse lookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int bignumz[16]; | |
int conv_bitz(int num) | |
{ | |
for ( int i = 0 ; i < 16; i++) { | |
//printf("Comparing %d with %d\n", num, ( 1 << i)); | |
//printf("AND is %d\n", num & ( 1 << i)); | |
if ( (num & ( 1 << i )) == num ) { | |
printf("%d is %d\n", num, i); | |
return i; | |
} | |
} | |
} | |
int main() | |
{ | |
for ( int i = 0; i < 16; i++ ) { | |
bignumz[i] = ( 1 << i ); | |
} | |
for ( int i = 0; i < 16; i++ ) { | |
printf("Bitwise %d is %d\n", i, bignumz[i]); | |
} | |
printf("====================================\n\n"); | |
for ( int i = 0; i < 16; i++ ) { | |
conv_bitz(bignumz[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment