Skip to content

Instantly share code, notes, and snippets.

@madcoder2k17
Created July 3, 2017 09:55
Show Gist options
  • Save madcoder2k17/009b2d7a0eb86d636790a663a7437daa to your computer and use it in GitHub Desktop.
Save madcoder2k17/009b2d7a0eb86d636790a663a7437daa to your computer and use it in GitHub Desktop.
It is a snippet of integer to binary.
void display_binary_n(int dec)
{
const int size = sizeof(int) * 8 ;
unsigned int current;
int i;
for( i = size - 1 ; i >= 0 ; i--)
{
current = 1<<i;
printf("%d",( (current & dec) != 0) ? 1: 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment