2 ms·
not in the sense where you would always keep in mind "there is one bit of sign and 7 bits of value", and not in the sense that you "can run the sign bit through
by fsckboy 4y ago
not in the sense where you would always keep in mind "there is one bit of sign and 7 bits of value", and not in the sense that you "can run the sign bit through an ALU adder as data, don't worry, it'll work". It's just a confusing way to think about it.
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.
- layer8 4y agoThe representation sure works differently from one’s complement, but it is still called the sign bit, because the number is negative if and only if that bit is set.
- fsckboy 4y agoyes, but my original comment did say don't "think" of it as a sign bit rather than don't call it that. 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.