As in title i'm trying to convert decimal number to binary. I set the lowest int as i coudl
char * toBinary(int num)
{
int i = 1 << 31;
while(i!=0)
{
if((num & i) == 0 )
printf("0");
else
printf("1");
i >>= 1;
printf("%d", i);
getchar();
}
}
but it does not work, after every shift i
is still negative number, what shoudl i change ?