Created
September 15, 2015 04:05
-
-
Save hydrocat/11d092e2d12ccb9d68ee to your computer and use it in GitHub Desktop.
Quick print decimal in binary using C
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
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc,char* argv[] ) | |
{ | |
int n = atoi(argv[1]); | |
int i=0; | |
for(; i < sizeof( int ) * 8 ; i++, n <<= 1 ) | |
{ | |
printf("%d", n<0 ? 1 : 0 ); | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment