by layer8 · 4y ago · 0 comments
one place where "the sign bit interpretation" shows up, is still not a slam dunk for sign bits. Using C as the example, when casting a signed char to a signed word, you do have to take the "sign bit" and extend it: but you don't just move it to the new sign bit, you extended it through all those other "data/value" bits.
and one's complement is a complement, but two's complement isn't really. It does turn out that if you take the complement and add one you get the right value, but a better way to think of it (on byte scale e.g.) is "take a modulo-256 dial, now change the labeling counter clockwise from the top to negative numbers because you note that 255+1 is 0 just like -1+1 is 0". I just think this explanation serves beginning C or ASM programmers better because it's more mentally agile.
I learned it what I would call "the dumb way", but since I was amazed that it worked I studied it to convince myself it was true and then I realized what was actually going on.