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.
Bit width
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
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
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
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.
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
@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?
