Sign-Magnitude Converter

Enter an integer and bit width to convert to sign-magnitude binary.

How it is calculated

For a bit width w, the leftmost bit is the sign (0 for positive or zero, 1 for negative) and the other w − 1 bits hold the absolute value in plain binary, padded with leading zeros. So binary = sign bit + binary(|value|). The value must fit: |value| ≤ 2w−1 − 1, so an 8-bit field covers −127 to 127 and a 4-bit field −7 to 7. The value must be a whole number, and the width a whole number from 2 to 63; if you leave the width empty it is 8. A number that is too large for the width, or a fraction, gives no result. Sign-magnitude has both +0 and −0, but the tool always writes zero with a 0 sign bit, so typing −0 gives 00000000.

Worked example

Convert −18 to 8-bit sign-magnitude. The number is negative, so the sign bit is 1. The magnitude is 18, which is 10010 in binary; padded to the 7 remaining bits that is 0010010. Putting them together gives 10010010, with sign bit 1 and magnitude 18. For comparison, +18 would be 00010010: only the first bit changes, whereas in two's complement −18 would be 11101110.

Try this example →

Common mistakes

  • Expecting 8 bits to reach −128. Sign-magnitude spends one bit on the sign, so the range is −127 to 127; 128 is too large and gives no result.
  • Choosing a width that is too small. −4 in 3 bits would need a magnitude of 100 in only two bits, so there is no answer; widen the field.
  • Mixing it up with two's complement. In sign-magnitude only the first bit differs between +18 and −18; there is no inversion and no adding one.
  • Looking for −0. The tool writes zero as all zeros, so −0 cannot be shown.
  • Typing a binary pattern or a fraction in the value box. The value is a whole decimal number such as -18: 10010 is read as ten thousand and ten, which does not fit in 8 bits, and 3.5 is not a whole number.

About this calculator

Sign-magnitude is one of the earliest schemes computers used to represent signed integers in binary: the leftmost bit is a dedicated sign bit (0 for positive, 1 for negative), and the remaining bits store the number's absolute value directly, unlike two's complement where negative numbers are encoded by inverting and adding one.

Sign-magnitude is simple to understand and easy to convert to and from decimal by hand, which is why it's still widely taught as the first step in binary number representation — but it has real drawbacks, like having two representations of zero (+0 and −0) and needing separate addition/subtraction logic, which is why almost all modern hardware uses two's complement instead. Computer science students and instructors use converters like this to build intuition for how signed binary representations work before moving on to two's complement.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    This tool only encodes, from a decimal number to bits; it does not decode a bit pattern back into a value. To read a pattern yourself, take the first bit as the sign and treat the rest as a plain binary number. That shows an oddity: 10000000 in 8 bits would mean negative zero, a pattern this converter never produces because zero is always written with a 0 sign bit. Which other encodings, such as one's complement, would you like to see added?

Popular calculators

All Calculators