Math
One's Complement Calculator
One's complement is the bitwise NOT of a number: every 0 becomes 1 and every 1 becomes 0.
It is the first step of two's complement and a signed-number system in its own right (with a quirky negative zero). Flip a pattern, encode a decimal at a chosen width, or decode a pattern, and compare with two's complement.
Digits 0 and 1. Every bit will be flipped, so include leading zeros if the width matters.
Try an example
Result
Result
—
- Two's complement
- —
- Hexadecimal
- —
- Range / width
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What the one's complement calculator solves
The one's complement of an n-bit pattern is what you get by inverting every bit; numerically it equals 2^n − 1 − x. Used as a signed representation, a leading 1 means negative and the The length or size of a vector, ignoring which way it points. is found by flipping the bits back. Because 0000…0 and 1111…1 both stand for zero, the range is symmetric: −(2^(n−1) − 1) to 2^(n−1) − 1.
One's vs two's complement (8-bit)
| Decimal | One's complement | Two's complement |
|---|---|---|
| 5 | 00000101 | 00000101 |
| −5 | 11111010 | 11111011 |
| −1 | 11111110 | 11111111 |
| 0 | 00000000 or 11111111 | 00000000 |
| −127 | 10000000 | 10000001 |
| −128 | not representable | 10000000 |
How to use it
- Choose Flip the bits to invert any pattern (the width is whatever you type).
- Choose Decimal → one's complement to encode a signed number at 8, 16, 32, or 64 bits.
- Choose One's complement → decimal to decode a pattern; a leading 1 means negative.
- Compare the two's complement column: for negatives it is always the one's complement plus 1.
How to read the answer
The result is the flipped pattern or the decoded decimal. Hex is shown for register views. If a decoded pattern is all ones, the calculator reports negative zero, the reason most hardware moved to two's complement.
Common mistakes and edge cases
- Flipping only the bits after the first 1. One's complement flips every bit including leading zeros.
- Expecting −128 to fit in 8-bit one's complement. The range is −127 to 127.
- Confusing one's and two's complement of a negative number: they differ by exactly 1.
- Flipping a pattern without leading zeros changes its width: NOT 101 is 010, but NOT 00000101 is 11111010.
Worked examples
Flip a byte
00000101 → NOT
Result
11111010
Encode a negative
−5 at 8 bits
Result
11111010
Encode a positive
42 at 8 bits
Result
00101010
Decode a negative
11111010 as 8-bit
Result
-5
Negative zero
11111111 as 8-bit
Result
-0 (negative zero)
Out of range
−128 at 8 bits
Result
—
Invalid bit
10201
Result
—
Frequently asked questions
What is one's complement?+
The result of flipping every bit of a binary number. 00000101 becomes 11111010. As a signed system, a leading 1 marks a negative number whose magnitude is the flipped pattern.
What is the difference between one's and two's complement?+
Two's complement adds 1 after flipping. That removes the duplicate zero and makes the range asymmetric (−128 to 127 in 8 bits), which is why modern hardware uses it.
Why does one's complement have a negative zero?+
Flipping 00000000 gives 11111111, so both patterns mean zero. Arithmetic has to treat them as equal, which complicates circuits.
How do you find the one's complement of a decimal number?+
Write its magnitude in binary at the register width, then flip every bit if the number is negative. Positive numbers are unchanged.
Is one's complement still used?+
Rarely for integers, but the Internet checksum in IP, TCP, and UDP headers is computed in one's complement arithmetic.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Two's Complement Calculator
Convert decimal to two's complement and back at 4, 8, 16, 32, or 64 bits with the invert-and-add-1 steps, the sign bit highlighted, overflow detection, and the unsigned reading of the same bits.
Bitwise Calculator
AND, OR, XOR, NOT, NAND, and NOR on binary, decimal, octal, or hex inputs at 4 to 64 bits, with an aligned bit grid, a bit-by-bit truth table, and the result in every base.
Binary to Decimal Converter
Convert binary to decimal with the positional-weight table (bit × 2^n), fractional bits after the binary point, and an option to read the bits as a signed two's complement number.
Decimal to Binary Converter
Convert decimal to binary with the repeated-division steps, fractional parts by repeated multiplication (0.625 → 0.101), repeating-fraction detection, and negatives as a sign or two's complement.
Bit Shift Calculator
Left, logical right, and arithmetic right shifts at 4 to 64 bits with the before/after bit rows, bits shifted out, overflow detection, and the ×2^n or ÷2^n meaning of the shift.
Binary Calculator
Add, subtract, multiply, or divide binary numbers with the column method shown: carries, borrows, partial products, and a long-division tableau, plus decimal, hex, and octal equivalents.
Last updated: September 4, 2026