Print a char value(ch variable here) in binary:
printf("%c%c%c%c%c%c%c%c",
(bitMap[i]&0x80)?'1':'0',
(bitMap[i]&0x40)?'1':'0',
(bitMap[i]&0x20)?'1':'0',
(bitMap[i]&0x10)?'1':'0',
(bitMap[i]&0x08)?'1':'0',
(bitMap[i]&0x04)?'1':'0',
(bitMap[i]&0x02)?'1':'0',
(bitMap[i]&0x01)?'1':'0');
2 comments:
I think, the code given above is the processor coed for the translation of the numeric value into the binary one. There is the direct allocation to the register of the variable. According to me, there should be some other way to redirect that.
there are lots of way to get to this, this is just an AND operator with constant numbers which gives you the value of one bit in the byte of char.
Post a Comment