One’s Complement Calculator
Choose binary or signed decimal input and a width from 2 to 4096 bits. See the encoded word, its bitwise complement and the signed decimal value of the word.
Formula
For a negative value −m: code = 2ʷ − 1 − m. Complement = (2ʷ − 1) − code.
How to use
- Choose binary or decimal input.
- Enter a value and the word width.
- Read the complement, encoded word and signed decimal value.
Examples
- In 8 bits, 01010111 represents 87; its complement is 10101000, representing −87.
Frequently asked questions
What is the signed range?
For w bits it is −(2^(w−1)−1) to +(2^(w−1)−1). Eight bits hold −127 to +127.
Why are there two zeros?
All-zero bits represent +0; all-one bits represent −0. Enter -0 in decimal mode to preserve negative zero.
How are shorter binary inputs handled?
They are padded with zeros on the left before decoding. Use the full width for a negative bit pattern; longer inputs are rejected.
Sources
Updated: