Subj : Re: bit shifting To : comp.programming From : Willem Date : Sun Aug 14 2005 08:20 pm Rob wrote: ) My apologies for not getting all of this too quickly - I do feel like a bit ) of a dope. Anyway, I *think* I understand, so lets see if what I think is ) happening, is really happening. ) ) On paper, if I write down the number 128(decimal) in binary, it would look ) like this: 10000000 ) ) On paper, if I write down the number 127(decimal) in binary, it would look ) like this: 1111111 ) ) On paper, if I take 10000000 and do a complement operation on it, I get ) this: 01111111 ) ) But, on my computer,I am thinking 128 binary might look something more like ) this: 000...010000000, so that when I perform a complement operation on ) it, all the bits *before* the 1 and *after* get flipped, like so: ) 111...101111111. Does that make sense, and I am correct? You've almost got it. A variable has a very specific number of bits, and the ~ operator flips every one of them. shorts usually have 16 bits nowadays. You want 'char' for 8 bits. So, a 'short' value of 128 (decimal) would be 0000000010000000 binary. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT .