# Why was ones-complement integers implemented? [duplicate]

Wikipedia’s article on ones’ complement mentions large brands using it in their hardware for integer arithmetic into the late 1980s. This is surely for backwards compatibility?

According to the article, in 1952 the IBM 701/702 used twos’ complement, i.e. the integer representation method was well-known.

The IBM archives description for the 701 is somewhat non-supportive of the wiki article saying 35 bits and a sign.

Why did ones’ complement come to exist in computer hardware in the first place?

I'm also curious why it was so long lasting.

(As a university prof I'm also really curious why ones-complement is still presented in many introductory textbooks as a reasonable alternative to 1 + (−1) = 0. But that's for CS Educators Stack Exchange.)

Simpler encoding of negative numbers in the hardware↔user boundary is the only reasonable explanation I can think of. That would account for a 6-month fad. Not a blemish in the C and C++ specifications for several decades.

The invented part in the rubric might be trivially a one bit sign.

• I am aware of retrocomputing.stackexchange.com/questions/7095/… Commented Mar 4, 2022 at 20:10
• @Raffzahn No. I'm more interested why it it was implemented in the first place. 2-s complement was not unfamiliar. Commented Mar 4, 2022 at 21:41
• While I understand the advantages of twos-complement over ones, there is a certain symmetry to ones-complement which part of my mind finds appealing. For a 16-bit integer, having exactly 32,767 values both positive and negative is balanced (unlike the 32,768 negative numbers in twos-complement). Sure you end up with a positive and negative 0, neither unsigned, but in a way that's balanced too. Commented Mar 4, 2022 at 21:52
• The linked wikipedia page does not seem to mention the 701 (and the only recent edits seem to be squabbling about "ones'" versus "one's" complement). But the 701 was definitely sign and magnitude, not ones' complement.
– dave
Commented Mar 5, 2022 at 3:05
• Wiki article? On which wiki? Commented Mar 5, 2022 at 11:15

Why was ones-complement integers implemented?

Same question could be made about why decimal or other forms of representation were implemented - they seemed as a good idea to some developers for various factors, as each has it's advantages and disadvantages. Just think that early US machines were mostly decimal, while European developments more often preferred binary.

The wiki article mentions several large brands using ones-complement in their hardware for integer arithmetic into the late 1980's. This is surely for backwards compatibility?

Sure. after all, as new one's complement was only used by very few machines, ad only heritage lines that survived due their usage in large scale mission critical applications kept it - exactly because of preserving the immense investment done over decades of software development.

Unisys is the prime example here. Their machines were never sold in large numbers, but whoever used them in the 1950s/60s had for sure not only an extreme high demand (why else investing incredible amounts of money back then) and thus an even higher need to preserve that.

As usual it also takes two - in this case a manufacturer that is fine with catering to a closed circle of customers paying a premium to keep their ecosystem viable.

Why did ones-complement come to exist in computer hardware in the first place?

It was a viable bet.

• it's not more complicated than two's complement
• it may save some circuitry (quite important early on)
• it can be faster than two's complement on implementation level

Negation can be implemented extreme simple and in a way to add next to no delay. This is important as the main disadvantage of one's complement, a signed zero, can be avoided by using a subtraction instead of an addition, after negating the second operand. All decision needed can be done with simple single level logic gates, increasing execution speed.

I'm also curious why it was so long lasting.

See above. Real world application do differ a lot from teaching/scientific environment. For most scientific application change of hardware or OS isn't a big thing, as most applications are only used for a short time, one off, or reimplemented anyway. In the commercial world the focus is on running existing software. All development investment is focused on operation and extension, not rewriting.

Rewriting a financial application is measured in double or tripple digit man years - not counting all reliability problems that rewriting may bring. In this class it's literally cheaper to finance the continued development of an 'odd' computer architecture for a single user than porting its software.

• Are there any situations, other than parallel I/O, where ones'-complement offers any advantage? I suspect that many mechanical adding machines which could handle negative values did so with nines' complement because it's much easier for a printing mechanism to handle negative numbers in nines'-complement than in tens'-complement. I can't think of any other situation where ones'-complement would be cheaper, but there are many where it would be more expensive. Commented Mar 5, 2022 at 21:04
• @supercat the conversion advantage is true for 1's complement. Commented Mar 5, 2022 at 21:26
• What "conversion advantage" are you talking about other than parallel I/O? If one wanted to have a circuit that would accept a parallel binary input and display positive values in binary using a sequence of green light bulbs, and negative numbers in binary using a sequence of red light bulbs, the circuitry required to handle ones'-complement would be much simpler than that required to handle two's-complement, but if I/O is going to involve the CPU, having code convert two's-complement values to sign-magnitude for I/O is simpler yet. Commented Mar 5, 2022 at 21:33
• Any information that is structured as words is by nature parallel, even if transferred serial. Commented Mar 5, 2022 at 23:18
• The amount of hardware required to increment a value sent one bit at a time in LSB-first order is pretty tiny, especially if the system has a multi-phase clock available. One needs a carry latch which can be set or cleared before processing a number, based upon whether it should be incremented, an XOR gate, and a circuit to clear the carry latch after having processed an incoming zero bit. Probably under a dozen transistors total, to handle any number of bits, if one needs to have cleanly-buffered inputs and outputs; fewer if one can get by with outputs that may not switch totally cleanly. Commented Mar 5, 2022 at 23:56

Why did ones-complement come to exist in computer hardware in the first place?

It's just the same reason why ten's complement and nine's complement exist in decimal. In fact the method of complements for representing negative numbers existed long before binary computers. Mechanical decimal calculators can use either of them

Why did ones-complement come to exist in computer hardware in the first place?

Raffzahn already gave many great reasons from a hardware perspective. On the software side it has an advantage that makes it exists even until now: "endianness-resistant". It's used in the checksum of some software and most importantly in IPv4 header. When summing the array you don't need to operate on bytes but on words and reduce to byte later because the byte order isn't important due to the wrap-around carry

• The latter seems not so much about the order of bytes, but rather byte-wise vs word-wise sum. Commented Mar 5, 2022 at 18:37
• The fact that something like a TCP checksum is endianness-agnostic may have been desirable politically, but makes it more expensive to calculate on almost any platform than a fixed-endianness checksum would have been, even on platforms whose endianness was opposite that of the checksum. Commented Mar 5, 2022 at 21:06