View Single Post
Old Jul 27th, 2007, 5:37 AM   #4
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
I'd rather stick with my(or Herb's example). I think it's easier to follow. I do like his books cuz he provides lots of cool little programs to work with. But his coding style is really bad as far as his use of whitespace.

Getting back to my original question. How does the compiler know to only work with one column at a time? I can clearly see that is what the compiler is doing here. If you have an integer like 123(0111 1011), and your mask is set to 128(1000 0000) when you AND 0 and 1 you print 0. Then you move over to the right one column and you AND 1 and 1 and you print 1. Then you move over to the right one column and you AND 1 and 1 and you print 1.

You work with one column at a time. I know how the boolean AND works. You only get a 1 if both bits are set to 1. But does the fact that my mask is only has a 1 in just one bit position at at time, and 0's in all the other bit positions, does this make the compiler not see all those other columns? I am working with an 8 bit integer, so I have 8 columns.
357mag is offline   Reply With Quote