Name: Anonymous 2015-01-20 23:15
Sure, Two's Complement is nice and all because it increments easily, but that isn't enough to make it the definite best. For example, One's Complement and Sign and Magnitude both allow negative zero, so that's pretty neat. That would be great for error checking with sentinels. A function can return 0 or -0 for failure, both of which will evaluate to false in a logical statement, but -0 can be indicative of not just false, but failure. They both have the advantage of simplicity as well. Sign and Magnitude makes it very easy to see at a glance what the number is and is the closest to negative decimal values. One's Complement is also very easy because to negate the number, just NOT the number. Subtraction is thus reduced to
Which do you prefer /prog/?
a - b = a + ~b
. The advantages of Excess-k are harder to see. So hard to see that I can't think of any. It just offsets. Seems useless and annoying. A less direct method could be using the unused values in a binary coded decimal to signify the sign, but you would still be using binary coded decimal. Gross.Which do you prefer /prog/?