Lably
Skip to content

Ones' complement

Mathematics concept

  • 6 min read
  • 4 chapters

Related on Lably

Through Binary number, Computer science and Two's complement

A ones' complement system or ones' complement arithmetic is a system in which negative numbers are represented by the inverse of the binary representations of their corresponding positive numbers. In such a system, a number is negated (converted from positive to negative or vice versa) by computing its ones' complement. An N-bit ones' complement numeral system can represent integers in the range −(2N−1−1) to 2N−1−1; in contrast, a two's complement numeral system can represent integers in the range −2N−1 to 2N−1−1 (note that the range of negative integers is larger by one). It is one of three common representations for negative integers in binary computers, along with two's complement and sign-magnitude.

The ones' complement binary numeral system is characterized by the bit complement of any integer value being the arithmetic negative of the value. That is, inverting all of the bits of a number (the logical complement) produces the same result as subtracting the value from 0.

Many early computers, e.g., the UNIVAC 1101, CDC 160, CDC 1604, CDC 6600, LINC, DEC PDP-1, UNIVAC 1107, and their successors, used ones' complement arithmetic. Successors of the CDC 6600 continued to use ones' complement arithmetic until the late 1980s, and the descendants of the UNIVAC 1107 (the UNIVAC 1100/2200 and Unisys ClearPath Dorado series) continue to use ones' complement, but all modern computers use two's complement. (Current Unisys ClearPath Dorado machines emulate the ones' complement 36-bit instruction set on two's complement processors.)

Programming language standards such as C++20 and C23 require two's complement and disallow other representations such as ones' complement.

Number representation

Positive numbers are the same simple, binary system used by two's complement and sign-magnitude. Negative values are the bit complement of the corresponding positive value. The largest positive value is characterized by the sign (high-order) bit being off (0) and all other bits being on (1). The lowest negative value is characterized by the sign bit being 1, and all other bits being 0. The table below shows all possible values in a four-bit system, from −7 to +7.

+ − 0 0000 1111 — Both +0 and −0 return TRUE when tested for zero 1 0001 1110 — and FALSE when tested for non-zero. 2 0010 1101 3 0011 1100 4 0100 1011 5 0101 1010 6 0110 1001 7 0111 1000

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication