Advanced

One's Complement & Sign-Magnitude Calculator

See how a signed integer is encoded in sign-magnitude, one’s-complement, and two’s-complement form at 8, 16, or 32 bits.
Whole number, positive or negative

Bit width

Total bits used to store the value
Two’s complement (8-bit)
1101 0011
Sign-magnitude
1010 1101
One’s complement
1101 0010
Decimal value
-45
Magnitude
45
Sign
Negative
Two’s-comp as unsigned
211
Representable magnitude
0 – 127
-127-95.3-63.5-31.8031.863.595.3127Signed value within the representable range
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Enter a signed integer and bit width to see its sign-magnitude, one’s-complement, and two’s-complement binary side by side. Positives are identical; negatives differ. Sign-magnitude and one’s complement each have two zeros (+0 and -0), while two’s complement has one unique zero, making it the standard in modern computers.

Formula
Sign-magnitude = sign bit + |v| (w-1 bits); One’s complement (negative) = NOT(|v|) in w bits; Two’s complement (negative) = 2^w - |v| = one’s complement + 1
How this is calculated

Enter a signed integer v and pick a bit width w (8, 16, or 32). The magnitude |v| is written in binary, then each of the three classic signed encodings is built from it. Sign-magnitude uses the most-significant bit as a pure sign flag (0 = positive, 1 = negative) and stores |v| in the remaining w-1 bits, so its representable magnitude is 0 to 2^(w-1) - 1.

One’s complement keeps positive numbers as their plain unsigned binary and represents a negative number by flipping every bit of |v| within w bits, which equals (2^w - 1) - |v|. Two’s complement keeps positives the same but represents a negative as 2^w - |v|, exactly one greater than the one’s-complement pattern. Reading a two’s-complement pattern as an unsigned number therefore gives 2^w - |v| for negatives.

A key edge case is zero: sign-magnitude and one’s complement both admit two distinct bit patterns for zero (+0 = all zeros, -0 = sign bit / all ones), while two’s complement has a single unique zero, which is why it is the dominant choice in modern hardware. This tool restricts |v| to 2^(w-1) - 1 so the value fits all three encodings; values outside that range (including the most-negative two’s-complement value -2^(w-1)) are reported as out of range.

Frequently asked questions

For non-negative values, sign-magnitude, one’s complement, and two’s complement all store the plain unsigned binary of the number with a leading 0 sign bit, so the patterns match. They only diverge for negative values.

Both schemes can represent +0 (all zeros) and -0 (sign bit set, or all ones in one’s complement). Having two encodings for zero complicates comparisons and arithmetic, which is one reason two’s complement, with its single zero, is preferred.

Two’s complement can store -2^(w-1), but sign-magnitude and one’s complement cannot, because their magnitude field only holds up to 2^(w-1) - 1. To keep all three encodings comparable, this calculator limits |v| to 2^(w-1) - 1.

Also known as

ones complement calculator
sign magnitude
signed number representation
ones complement converter
negative binary encoding
one's complement

APA

TG we-Calculate Editorial Team. (2026). One's Complement & Sign-Magnitude Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/ones-complement-sign-magnitude-calculator

Chicago

TG we-Calculate Editorial Team. "One's Complement & Sign-Magnitude Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/ones-complement-sign-magnitude-calculator.

IEEE

TG we-Calculate Editorial Team, "One's Complement & Sign-Magnitude Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/ones-complement-sign-magnitude-calculator

BibTeX

@misc{wecalculate_ones_complement_sign_magnitude_calculator, title = {One's Complement & Sign-Magnitude Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/ones-complement-sign-magnitude-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?