Created
August 29, 2020 12:20
-
-
Save wukaihua119/cb4c7a0872cc3d7704fe58604f2a6059 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// using mask to convert the integer to binary. | |
void printBin( int num ){ | |
int mask = 1 << 7; // 10000000 | |
for( int i = 0; i < 8; ++i ){ | |
printf( "%d", ((( num & mask ) == 0 )? 0:1) ); | |
mask >>= 1; | |
} | |
printf( "\n" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment