Convert between decimal and one's complement binary representation. View bit flipping, sign detection, range tables, and comparison with two's complement.
One's complement is a binary number representation for signed integers where negative numbers are formed by flipping every bit of the positive value. In an 8-bit system, +42 is 00101010, and −42 is simply 11010101 — every 0 becomes 1 and every 1 becomes 0. The most significant bit serves as the sign bit: 0 for positive, 1 for negative. One peculiarity of one's complement is that it has two representations of zero: +0 (00000000) and −0 (11111111).
While modern computers universally use two's complement (which eliminates negative zero and simplifies hardware), one's complement remains historically important and still appears in certain protocols. The Internet Protocol (IP) header checksum, defined in RFC 1071, uses one's complement arithmetic specifically because the end-around carry property makes it order-independent — you can sum the fields in any order and get the same checksum.
This calculator converts between decimal and one's complement binary for 4-bit, 8-bit, and 16-bit widths. It shows the bit-by-bit visualization with the sign bit highlighted, demonstrates negation by bit flipping, displays the valid range for each bit width, and provides a detailed comparison with two's complement to help you understand both representations.
Understanding one's complement is essential for networking professionals (IP checksum computation), computer science students studying number representations, and anyone working with legacy systems. This calculator instantly shows the bit-level representation, handles edge cases like negative zero, and provides side-by-side comparison with two's complement — making it far faster and less error-prone than manual bit flipping.
One's complement negation: flip all bits. For n-bit: −x = (2ⁿ − 1) − x. Range: −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1). Two representations of zero: +0 and −0.
Result: One's complement: 11010101, Hex: 0xD5
+42 in binary is 00101010. Flipping all bits gives 11010101, which is −42 in one's complement. The sign bit is 1 (negative), and the magnitude bits 1010101 decode to the complement.
In one's complement, positive numbers use standard binary representation with the MSB (most significant bit) as 0. To negate a number, every bit is flipped: 0→1 and 1→0. This is equivalent to computing (2ⁿ − 1) − x for an n-bit number. For 8 bits, the range is −127 to +127 with two representations of zero. Addition in one's complement requires end-around carry: if the addition produces a carry out of the MSB, that carry is added back to the LSB. This rule ensures that +0 + (−0) = +0 correctly.
One's complement was used in several early computers including the CDC 6600 (1964), the UNIVAC 1107, and the PDP-1. These machines implemented one's complement arithmetic directly in hardware. However, the duplicate zero and end-around carry complicated both hardware design and software. As transistor technology improved, the slightly more complex two's complement gained favor because it eliminated −0, simplified the ALU (arithmetic logic unit), and provided one extra representable value. By the 1970s, most new processor designs had adopted two's complement.
Despite its obsolescence in CPU arithmetic, one's complement survives in the Internet Protocol suite. RFC 1071 defines the IP header checksum as the 16-bit one's complement of the one's complement sum of all 16-bit words in the header. The key advantage is that this checksum is byte-order independent and can be computed incrementally — useful for routers that modify TTL fields without recomputing the entire checksum from scratch. UDP and TCP checksums use the same algorithm.
One's complement is a binary representation for signed integers where negative numbers are formed by inverting (flipping) all bits of the positive value. The MSB serves as the sign bit: 0 = positive, 1 = negative.
Flipping all bits of +0 (00000000) gives 11111111, which represents −0. Both patterns decode to zero, but they have different bit representations, creating an ambiguity that two's complement eliminates.
Add the binary numbers normally. If there is a carry out of the MSB, wrap it around and add 1 to the LSB (end-around carry). This extra step is needed because of the duplicate zero representation.
Two's complement has a unique zero (no −0), one extra negative value, and simpler addition hardware (no end-around carry needed). These advantages make it more efficient for CPU design.
The main modern use is the Internet Protocol (IP) header checksum (RFC 1071). One's complement addition is order-independent, meaning bytes can be summed in any order — a useful property for checksums.
One's complement flips all bits to negate; two's complement flips all bits and adds 1. One's complement has ±0 and symmetric range; two's complement has unique zero and one extra negative value.