Convert between decimal and sign-magnitude form, where the leftmost bit is purely a sign flag and the rest is the ordinary magnitude – intuitive, but with two zeros.
Show calculation steps
Processed privately in your browser — nothing you paste is uploaded, logged or stored.
The human-intuitive encoding
Sign-magnitude mirrors handwriting: one bit says negative-or-not, the remaining bits hold the ordinary magnitude. −42 at 8 bits is simply 1 (sign) followed by 0101010 (42). Decoding splits the fields back apart — both directions live on this page.
Intuitive for humans, awkward for adders: the scheme forces sign-comparison logic before any addition, which is why hardware abandoned it for integers while keeping it for the one place it shines.
Worked example
Encode −42, width 8: sign 1 | magnitude 0101010 → 10101010 Decode 10101010: sign 1 → negative; magnitude 0101010 = 42 → −42
Where it lives on: floating point
Every IEEE-754 float is sign-magnitude at heart — a sign bit over an unsigned magnitude built from exponent and mantissa. The famous ±0 pair of floating point is inherited sign-magnitude behaviour, and comparisons must special-case it, exactly as integer sign-magnitude always had to.
The two zeros
0…0 is +0 and 1 followed by zeros is −0: distinct patterns, equal value. Sorting, equality and hashing all need a rule for the pair. This redundancy — one wasted pattern and endless special cases — is the textbook argument the scheme lost on.
Privacy
Encoding and decoding are local; patterns never leave your device.
How to use the Sign-Magnitude Converter
- Choose the direction: decimal to sign-magnitude, or pattern to decimal.
- Set the bit width.
- Enter the value or pattern and click "Convert".
- The steps separate the sign bit from the magnitude field explicitly.
Frequently asked questions
How does sign-magnitude represent a number?
The leftmost bit is purely a sign flag (0 positive, 1 negative); the remaining bits are the ordinary magnitude. −42 at 8 bits is 1 followed by 0101010: sign 1, magnitude 42.
Why is this scheme intuitive but awkward for hardware?
It matches how humans write numbers (sign, then digits), but the arithmetic branches: adding +5 and −3 needs comparison and subtraction machinery rather than one uniform adder. Two's complement removed that branching, which is why CPUs use it.
Where does sign-magnitude survive today?
In floating point: the IEEE 754 sign bit is exactly a sign-magnitude flag over the magnitude formed by exponent and mantissa. That is why floats have both +0 and −0 – inherited sign-magnitude behaviour.
What are +0 and −0 here?
All-zeros with sign 0, and 10000000 with sign 1 at 8 bits. Two distinct patterns, equal value – comparisons must treat them as equal, which is extra logic the scheme forces.
What range fits in 8 bits?
±127: one bit for sign leaves seven magnitude bits (max 1111111). The tool tells you exactly when a magnitude will not fit the chosen width.
How does decoding differ from two's complement decoding?
Sign-magnitude reads the LOW bits as a plain magnitude regardless of sign – so 10101010 is −42 here but −86 in two's complement. Same bits, different arithmetic: the comparison is the whole lesson.
Is the sign-magnitude conversion processed locally?
Yes – conversion happens in your browser; patterns never leave the page.