0

http://i54.tinypic.com/4zymi0.jpg

can someone please explain how does the sizeof() and the mask help me on converting from dec to binary? and also bit shift?

this what i got now: i followed the book says to bit-wise & the mask and my input;
but the mask is ending with 0s(0x80000). isnt that will make all the num into 0? and i have no idea what does the sizeof() and the bit-shift works?

thanks

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by wildplace
1

Consider a smaller example:

1000 0000   //0x80 as a mask

Take the number:
0100 0110   //70 decimal  & it with
1000 0000  = 0000 0000, first digit is 0

<shift bit of mask to the right>
0100 0000 & it with
0100 0110 = 0100 0000 => second digit is 1

<shift bit of the mask to the right>
0010 0000 & with the original number

etc.

So, you're using & to test the bits one by one to see if the given number's bits are 1 or not. If they are 1, the and of the bit in the original number with the mask is 1.

The mask allows us to focus on the bits one at a time.

Votes + Comments
explain well, thanks =]
0

i really appreaciate for your hlep. and you explain very well =] thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.