odd binary bahavior

Started by
9 comments, last by Conner McCloud 18 years, 4 months ago
Quote:Original post by xeddiex
Ok, SiCrane. I hope I got this right.


You said promotion from said types preserves value and signdness:

signed short: 1111 1111 1111 1111

After promotion to signed int: 1000 0000 0000 0000 1111 1111 1111 1111

After reading, Conner's latest post; it's as I suspected; All the bits get set but I'm not quite understanding why *all* the bits in the "promoted to signed int" are being set to 1 if the value being preserved only takes up the first half of the WORD and it should look like in the above example. Hmm, so I guess it preserves more than the value and signedess? everything after the first half, regardless if the bits are set or not are set to 1?

Look up twos-complement arithmetic. Wikipedia had an excellent article on the subject.

CM

This topic is closed to new replies.

Advertisement