Recently i saw a code that prints number in binary system.
I dont understand line : bit = (dec & 0x8000) != 0;
Is there's anyone that can explan this to me?
int dec,n ;
short bit;
printf("Insert number: ");
scanf("%d", &dec);
if (dec == 9999) printf(" Out of range!");
for (int i = 1; i <= 16; i++) {
bit = (dec & 0x8000) != 0;
printf("%d", bit);
if (i % 4 == 0) printf(" ");
dec <<= 1;
}
printf("\n");
return 0;
}