Skip to content
Math

One's Complement Calculator - Binary, Decimal and Hex

Enter a number in decimal, binary, or hexadecimal format, choose a bit width, and this calculator instantly returns the one's complement in all three bases. The step-by-step panel shows every conversion and bit-flip so you can follow the working. Results update as you type.

Your details

Choose the base of the number you are entering. Decimal is the standard base-10 system; binary uses only 0s and 1s; hexadecimal uses digits 0-9 and letters A-F.
Enter the number to convert. For decimal, type a non-negative integer. For binary, type 0s and 1s only. For hex, use digits 0-9 and A-F (case-insensitive, 0x prefix optional).
The total number of bits used to represent the number. 8-bit is standard for single bytes; 16-bit covers short integers; 32-bit covers most modern integer types.
One's complement (binary)
1101 0101

The bitwise NOT of the input, padded to the chosen bit width.

One's complement (decimal)213
One's complement (hex)D5
Input as binary0010 1010
Input as decimal42
Input as hex2A

One's complement of 42 in 8 bits is 213 (1101 0101).

  • In 8-bit one's complement, the complement of 42 is 213 (0xD5).
  • Adding the original and its complement always gives 255 (all 1s), which equals 2^8 - 1.
  • One's complement is simply bitwise NOT: every 0 becomes 1 and every 1 becomes 0.
  • 8-bit one's complement can represent signed integers from -127 to +127 (it has two zeros: 0000 0000 and 1111 1111).

Next stepFor modern signed-integer arithmetic, two's complement (add 1 to one's complement) is the standard because it eliminates the double-zero problem.

What is one's complement?

One's complement is a binary representation scheme where the negative of a number is found by flipping (inverting) every bit. For any N-bit binary number, its one's complement is computed as (2^N - 1) - x, which is equivalent to a bitwise NOT operation. For example, the 8-bit binary for 42 is 0010 1010, and its one's complement is 1101 0101 (213 unsigned). Adding any number to its one's complement always yields a string of all 1s: 0010 1010 + 1101 0101 = 1111 1111 = 255 (for 8-bit). One's complement was used in early computers such as the CDC 6600 and UNIVAC systems as a way to handle signed arithmetic, though modern hardware has largely shifted to two's complement because it avoids the double-zero problem.

How to calculate one's complement step by step

1. Write the number in binary. For decimal input, convert using repeated division by 2. For hex input, replace each hex digit with its 4-bit equivalent. 2. Pad the binary to the desired bit width (4, 8, 16, or 32 bits) by adding leading zeros. 3. Flip every bit: change each 0 to 1 and each 1 to 0. The result is the one's complement. 4. Optionally, convert back to decimal by treating the result as an unsigned binary number, or to hex by grouping bits into sets of four. Example: decimal 42 in 8-bit binary is 0010 1010. Flipping every bit gives 1101 0101, which equals 213 in decimal and D5 in hex.

One's complement vs two's complement

One's complement and two's complement are both methods for representing signed binary integers, but they differ in how they handle the most negative value and zero. One's complement has two representations for zero: all 0s (positive zero) and all 1s (negative zero). This double-zero complicates arithmetic circuits. Two's complement solves this by adding 1 to the one's complement of a number, which shifts all negative values by one and leaves only a single zero. Because of its simpler arithmetic rules and single zero, two's complement is used in virtually all modern CPUs, including x86, ARM, and RISC-V processors. One's complement remains useful in networking: the IPv4 and IPv6 checksum algorithms use one's complement addition precisely because the double-zero cancels out in practice during checksum verification.

Signed range and bit widths

The range of signed integers representable in N-bit one's complement is -(2^(N-1) - 1) to +(2^(N-1) - 1). For 8-bit: -127 to +127 (with two zeros). For 16-bit: -32767 to +32767. For 32-bit: -2147483647 to +2147483647. Compare this to two's complement, which reaches one extra negative value: -128 to +127 for 8-bit. The leading bit in one's complement acts as the sign bit (1 = negative, 0 = positive), but unlike sign-magnitude representation, the magnitude bits are also flipped rather than left unchanged. This calculator works with non-negative inputs and returns unsigned output values, which is the most common use case for one's complement in networking checksums and digital logic design.

One's complement reference table (8-bit, non-negative)

DecimalBinary (8-bit)1's ComplementComplement DecimalHex
00000 00001111 1111255FF
10000 00011111 1110254FE
20000 00101111 1101253FD
70000 01111111 1000248F8
100000 10101111 0101245F5
150000 11111111 0000240F0
420010 10101101 0101213D5
630011 11111100 0000192C0
1000110 01001001 10111559B
1270111 11111000 000012880
1281000 00000111 11111277F
2001100 10000011 01115537
2541111 11100000 0001101
2551111 11110000 0000000

Shows decimal, 8-bit binary, one's complement binary, and hex for common values.

Frequently asked questions

What is one's complement in binary?

One's complement is the value obtained by flipping every bit in a binary number. A 0 becomes 1 and a 1 becomes 0. For an N-bit number x, the formula is (2^N - 1) - x. The operation is also called bitwise NOT. For example, 0010 1010 (42 in decimal, 8-bit) becomes 1101 0101 (213 in decimal) after one's complement.

How do I convert a decimal number to one's complement?

First convert the decimal number to binary using the standard division-by-2 method. Then pad the result to your chosen bit width (for example 8 bits) with leading zeros. Finally, flip every bit. This calculator does all three steps automatically and also converts the result to hex.

Why does adding a number and its one's complement always give all 1s?

Because in binary, 0 + 1 = 1 and 1 + 0 = 1. Every bit position pairs a 0 from one number with a 1 from its complement, so every position sums to 1 with no carry. The result is always a string of N 1s, which equals 2^N - 1 (for example, 255 for 8-bit numbers).

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

One's complement flips all bits. Two's complement flips all bits and then adds 1. Two's complement has a single zero and a slightly wider negative range, which is why all modern processors use it. One's complement has two zeros (all-0s and all-1s) and is mainly used today in networking checksum algorithms such as IP and TCP/UDP checksums.

How do I convert one's complement back to decimal?

If the leading bit is 0, the number is positive: simply convert the binary string to decimal using standard binary-to-decimal conversion. If the leading bit is 1, the number is negative in a signed context: flip all bits to get the magnitude, then apply a negative sign. For example, 1101 0101 has a leading 1, so flip to get 0010 1010 = 42, and the signed value is -42.

Where is one's complement actually used today?

One's complement is used in IP, TCP, and UDP checksum computation as specified in RFC 791 and RFC 793. Routers and hosts sum 16-bit words in one's complement arithmetic, which has the useful property that any carry past the most significant bit wraps around and is added back in. This makes the checksum insensitive to byte ordering. Outside networking, it also appears in some FPGA and digital logic designs.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…