One's Complement Calculator

Convert between decimal and one's complement binary representation. View bit flipping, sign detection, range tables, and comparison with two's complement.

Range: -127 to 127
Decimal
42
Signed decimal value
One's Complement
00101010
8-bit one's complement representation
Hex
0x2A
Hexadecimal representation
Sign Bit
0 (positive)
Most significant bit indicates sign
Magnitude Bits
0101010
Remaining 7 bits encode the magnitude
Two's Complement
00101010
For comparison — two's complement of the same value
Bitwise NOT
11010101
All bits flipped — this is the negation in one's complement
Negative Zero?
Yes (1's comp has −0)
One's complement has two representations of zero

Bit-by-Bit Visualization

0
0
1
0
1
0
1
0
Sign bit   Magnitude bits

Negation by Bit Flipping

Bit Position76543210
Original00101010
Flipped (negation)11010101

8-bit One's Complement Range

DescriptionDecimalBinary
Maximum positive12701111111
Zero (+0)000000000
Negative zero (-0)-011111111
Maximum negative-12710000000

One's Complement vs Two's Complement

FeatureOne's ComplementTwo's Complement
Negation ruleFlip all bitsFlip all bits + add 1
Negative zeroYes (11111111)No
Range (8-bit)127 to +127128 to +127
Unique values255256
End-around carryRequired for additionNot needed
Modern usageLegacy (IP checksums)Standard in all CPUs
Planning notes, formulas, and examples

About the One's Complement Calculator

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.

When This Page Helps

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 page shows the bit-level representation, handles edge cases like negative zero, and provides side-by-side comparison with two's complement so the representation can be checked directly instead of reconstructed by hand.

How to Use the Inputs

  1. Select the conversion mode: Decimal to Binary or Binary to Decimal
  2. Choose the bit width (4, 8, or 16 bits)
  3. Enter a decimal number or binary string depending on the mode
  4. Use preset buttons for quick examples including negative zero
  5. View the bit-by-bit visualization with color-coded sign bit
  6. Examine the negation table showing original and flipped bits
  7. Compare one's complement with two's complement in the comparison table
Formula used
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.

Example Calculation

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.

Tips & Best Practices

  • One's complement has two zeros: +0 (all 0s) and −0 (all 1s)
  • Negation is simple: just flip every bit (bitwise NOT)
  • Addition requires 'end-around carry': if there's a carry out, add 1 to the result
  • The IP header checksum (RFC 1071) uses one's complement arithmetic
  • Modern CPUs use two's complement exclusively — one's complement is mainly historical
  • The range is symmetric: −(2ⁿ⁻¹−1) to +(2ⁿ⁻¹−1), wasting one pattern on −0

How One's Complement Works

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.

Historical Context

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.

One's Complement in Networking

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.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • 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.