One’s complement represents negative numbers by flipping all bits. It was used in early computers such as the CDC 6600 and survives in the Internet checksum used by IPv4, TCP and UDP.
How to use the One’s Complement Calculator
- Number of bits
- Conversion
- Decimal number
- Binary number
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Choose the number of bits and the direction. Note that one’s complement has two zeros: 0000… and 1111…
Formula
Negative x: invert every bit of |x| · range for n bits: −(2ⁿ⁻¹ − 1) to 2ⁿ⁻¹ − 1 (with +0 and −0)
Worked example
Inputs — Number of bits: 8; Conversion: Decimal → one's complement; Decimal number: -5.
Results — Result = 1111 1010; Binary of the absolute value / input = 0000 0101; Inverted bits = 1111 1010; Decimal value = -5; Steps = Write |-5| in binary (00000101) and flip every bit..
Key terms
- One's complement
- Bitwise inversion of a binary number.
Frequently asked questions
What is −5 in 8-bit one's complement?
1111 1010.
Why are there two zeros?
0000 0000 (+0) and 1111 1111 (−0).
Where is one's complement still used?
In the Internet checksum.
How does it differ from two's complement?
Two's complement adds 1 after inverting, removing the second zero.