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

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.

commented: explain well, thanks =] +2

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.