NUMBER THEORYBinaryMathematics Calculator
~

One's Complement

One's complement = flip every bit (0โ†’1, 1โ†’0). Same as bitwise NOT (~). Used in TCP/IP checksums, vintage computing, and DSP. Has two zeros: +0 and -0.

Concept Fundamentals
~
NOT Op
3
Formats
5
Bit Widths
100%
Bits Flipped

Did our AI summary help? Let us know.

TCP/IP checksum: RFC 1071 defines one's complement sum with wraparound carry. Double inversion returns original: ~~x = x. 8-bit range: -127 to +127 (two zeros: +0 and -0).

Key quantities
~
NOT Op
Key relation
3
Formats
Key relation
5
Bit Widths
Key relation
100%
Bits Flipped
Key relation

Ready to run the numbers?

Why: TCP/IP checksum uses one's complement addition. Early computers used it for signed integers before two's complement.

How: Invert each bit: 0โ†’1, 1โ†’0. Same as XOR with all 1s. Hardware: bank of NOT gates.

TCP/IP checksum: RFC 1071 defines one's complement sum with wraparound carry.Double inversion returns original: ~~x = x.

Run the calculator when you are ready.

Start CalculatingFlip all bits. Same as bitwise NOT. Binary, decimal, hex.
~
BINARY NUMBER

Ones Complement โ€” Binary Number Inversion

Flip every bit (0โ†’1, 1โ†’0). Same as bitwise NOT. Used in checksums, vintage computing, and DSP.

Input Format

Input & Bit Width

For educational and informational purposes only. Verify with a qualified professional.

๐Ÿงฎ Fascinating Math Facts

๐ŸŒ

TCP/IP checksum uses one's complement addition.

โ€” RFC 1071

๐Ÿ”€

Same as XOR with all 1s: x ^ 0xFF in 8-bit.

โ€” Digital Logic

๐Ÿ“‹ Key Takeaways

  • โ€ข The one's complement = flip all bits (0โ†’1, 1โ†’0): same as bitwise NOT (~)
  • โ€ข Negative zero problem: one's complement has two representations of zero (+0 = 00000000, -0 = 11111111)
  • โ€ข For n-bit signed integers, range is -(2^(n-1)-1) to +(2^(n-1)-1) (e.g., 8-bit: -127 to +127)
  • โ€ข Used in TCP/IP checksums, vintage computing (PDP-1), and DSP signal inversion

๐Ÿ’ก Did You Know?

๐ŸŒTCP/IP checksum uses one's complement addition โ€” RFC 1071 defines the algorithmSource: IETF RFC
๐Ÿ“ŸEarly computers (PDP-1, etc.) used one's complement for signed integers before two's complement became standardSource: Computer History
๐Ÿ”€Same as XOR with all 1s: x ^ 0xFF in 8-bit. Hardware implementation: a bank of NOT gatesSource: Digital Logic
โšกIn 8-bit: ~42 = 213 (0xD5). JavaScript bitwise ops use 32-bit, so ~42 in JS = -43Source: Programming
๐Ÿ“กSignal inversion in phase-shift keying (PSK) uses one's complement for phase modulationSource: Communications
๐Ÿ”ขDouble inversion returns original: ~~x = x. Inverting twice cancels outSource: Bitwise Math

๐Ÿ“– How Ones Complement Works

The one's complement of a binary number is obtained by inverting every bit. For each bit: 0 becomes 1, and 1 becomes 0. For example, 10101010 โ†’ 01010101.

Bitwise NOT Equivalent

In programming, this is the bitwise NOT (~) operation. In C, JavaScript, Java: ~x

Signed Interpretation

For signed integers, the MSB (most significant bit) indicates sign. 0 = positive, 1 = negative. The complement of a positive number gives its negative representation.

๐ŸŽฏ Expert Tips

Checksums

TCP/IP uses one's complement sum for header checksum โ€” wrap-around carry is added back

vs Two's Complement

Two's = one's + 1. Two's has single zero; one's has +0 and -0. Two's is standard for modern CPUs

Bit Width

Result depends on bit width. 8-bit ~42 โ‰  32-bit ~42. Always specify bit width for consistency

Double Inversion

~~x = x (inverting twice returns original). Useful for bit masking in unsigned context

โš–๏ธ Ones Complement vs Two's Complement

FeatureOne's ComplementTwo's Complement
OperationFlip all bitsFlip all bits + 1
Zero representation+0 and -0 (two zeros)Single zero
8-bit range-127 to +127-128 to +127
HardwareNOT gates onlyNOT + adder
Modern usageChecksums, DSPSigned integers (standard)

โ“ Frequently Asked Questions

What's the difference between one's and two's complement?

One's complement = invert all bits. Two's complement = invert all bits + 1. Two's is standard for signed integers because it has a single zero and simpler arithmetic.

Where is one's complement used today?

TCP/IP checksums (RFC 1071), vintage computing, simple encryption, signal processing, and DSP signal inversion.

What is the programming equivalent?

Bitwise NOT: ~x in C/JS/Java. JavaScript uses 32-bit for bitwise ops, so ~42 = -43 in JS.

Why does one's complement have two zeros?

+0 = 00000000, -0 = 11111111. Both represent zero. Two's complement avoids this by having only one zero.

What is the signed range for n-bit one's complement?

-(2^(n-1)-1) to +(2^(n-1)-1). For 8-bit: -127 to +127. For 16-bit: -32767 to +32767.

How does TCP/IP checksum use one's complement?

The checksum is the 16-bit one's complement of the one's complement sum of all 16-bit words in the header. Wraparound carry is added back.

Can I use one's complement for negative numbers?

Yes, but two's complement is preferred. One's complement requires special handling for -0 and end-around carry in addition.

What happens when I complement twice?

Double complement returns the original: ~~x = x. Inverting all bits twice cancels out.

๐Ÿ“Š Infographic Stats

~
NOT Op
3
Formats
5
Bit Widths
100%
Bits Flipped

โš ๏ธ Disclaimer: For unsigned interpretation. Signed one's complement has different semantics. JavaScript bitwise ops use 32-bit. Always verify with official sources for checksum implementations.

๐Ÿš€ DIVING IN
๐ŸŠLet's explore the numbers!
AI

Related Calculators