> At 02:21 PM 4/12/2007, William Couture wrote: > >>What's worse, I've worked with a control systems engineer (Ph.D., no >>less) who could not divide by 2 in his head... > > That's because he was having problems with the binary to decimal > conversion (in his head) after first converting the decimal value to > binary, then discarding the LSB. > > dwayne > This reminds me, I recently bought a textbook on digital design using VHDL. EVERY textbook I've seen says that to figure out the decimal equivalent of a negative twos complement number, take the twos complement (making it positive), convert to decimal, then add the minus sign. Something I read in BYTE magazine MANY years ago, that I have not seen published elsewhere, is, I think, much simpler. When using twos complement, make the sign of the weight of the msb negative. Then add up bits times weights, as usual. For example, in an 8 bit number, the msb weight becomes -128 instead of 128. So, 10101010 is: 1*(-128)=-128 0*64=0 1*32=32 0*16=0 1*8=8 0*4=0 1*2=2 0*1=0 and -128+32+8+2=-86. Doing it the "hard way," we do this: 10101010 01010101 - ones comp 01010110 - add one to get twos comp 64+16+4+2=86, but this is the opposite of our original number, so the original number was -86. In both cases, you have to add the product of bits and weights, but in the first method you don't have to twos complement. I always thought it was pretty clever... Harold -- FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist