Talk:Signed number representations

addition
I've spent ages trying to find this article! I think 'ones complement sum' should redirect here, too. I want to add that ones complement sum is used not only in IP header, but in TCP and UDP data as well. Its widespread is due to easy checksum verification - if there is arbitrary sequence of bytes, its checksum calculated according to ones complement arithmetic, always gives all-ones if you sum all data and checksum. But this checksum very simple and don't detect errors like swapped bytes.

Ones' Complement vs Sign-Magnitude
In the Ones' complement section there's this claim: "Note that the ones' complement representation of a negative number can be obtained from the sign-magnitude representation merely by bitwise complementing the magnitude." No matter how I look at this, I can't see how it is correct. It seems contradictory to the definition of ones' complement as well as the "Eight-bit ones' complement" table and the "Four-bit integer representations" in the Comparison table section.165.225.38.226 (talk) 19:18, 13 June 2018 (UTC)


 * The four-bit table shows that e.g. -1 is "1001" in sign-magnitude and "1110" in ones' complement representation. Bitwise complementing the magnitude means that you invert all the bits except the left-most bit (which is the sign bit). So "1001" becomes "1110", which supports the claim, so I don't see anything wrong with it. --Yawe (talk) 21:46, 13 June 2018 (UTC)


 * The one's complement representation of a negative number is obtained by complementing all the bits, and the signed-magnitude representation is obtained by complementing the sign bit, so if you take the signed-magnitude representation of a negative number, and complement the rest of the bits - i.e., complement the magnitude - you have complemented all the bits, and therefore now have the one's complement representation of that negative number. Guy Harris (talk) 23:04, 13 June 2018 (UTC)


 * More specifically, this is a convenient way to build sign-magnitude adders: Convert to ones complement, add (with end around carry), and convert back again. Gah4 (talk) 00:29, 14 June 2018 (UTC)

end-around carry
Regarding ones' complement, end-around carry, and the reference that can't be found. I believe I understand what the reference discusses, which is an effect using a ripple carry adder. But nobody uses a ripple carry adder! Seymour Cray, in his CDC days, believe that ones' complement adders were faster. But also note that, as written in the article, the end-around carry is done after the rest of the addition. If you use a carry-lookahead adder, like all real computers do, carries are computed at the same time as sum bits. A two's complement subtractor requires a carry-in to the LSB, which might need to propagate (hopefully though carry-lookahead) all the way. A ones' complement subtractor doesn't have that. But otherwise, WP:NOTHOWTO applies. There are things that computer designers need to know, but that we don't need to explain here. Gah4 (talk) 21:11, 25 March 2020 (UTC)

Negation in ones' complement
The article states that "...because the negation of a positive value x (represented as the bitwise NOT of x) can also be formed by subtracting x from the ones' complement representation of zero that is a long sequence of ones (−0)." yet when one goes to Ones' complement page it shows in the Negative zero section that addition or subtraction of negative 0 in binary has no effect on the number (as it shouldn't). As I understanding this sentence incorrectly or is it wrong? — Preceding unsigned comment added by 185.107.13.4 (talk) 14:08, 7 May 2020 (UTC)
 * No, it just says that for instance, on 5 bits, to obtain −3, i.e. written −11 in binary, one can do 11111 − 11 = 11100, i.e. 11100 is the representation of −3 on 5 bits. Vincent Lefèvre (talk) 17:17, 7 May 2020 (UTC)
 * Whether +0 or -0 is generated when the result is zero depends on some fine details of the logic, that we mostly don't need to go into here. There is one case that might be worth mentioning. You can build a ones' complement subtractor that only generates -0 when the first operand is -0. You can then do addition by adding the complement, or subtraction as subtraction. As long as the inputs are not -0, the result won't be -0. You can then get away with not comparing -0 and +0 equal, and otherwise not using -0. I don't know which machines, if any, do this. Gah4 (talk) 18:08, 7 May 2020 (UTC)
 * Whether +0 or -0 is generated when the result is zero depends on some fine details of the logic, that we mostly don't need to go into here. There is one case that might be worth mentioning. You can build a ones' complement subtractor that only generates -0 when the first operand is -0. You can then do addition by adding the complement, or subtraction as subtraction. As long as the inputs are not -0, the result won't be -0. You can then get away with not comparing -0 and +0 equal, and otherwise not using -0. I don't know which machines, if any, do this. Gah4 (talk) 18:08, 7 May 2020 (UTC)
 * Whether +0 or -0 is generated when the result is zero depends on some fine details of the logic, that we mostly don't need to go into here. There is one case that might be worth mentioning. You can build a ones' complement subtractor that only generates -0 when the first operand is -0. You can then do addition by adding the complement, or subtraction as subtraction. As long as the inputs are not -0, the result won't be -0. You can then get away with not comparing -0 and +0 equal, and otherwise not using -0. I don't know which machines, if any, do this. Gah4 (talk) 18:08, 7 May 2020 (UTC)