Two's Complement to Signed Magnitude Converter – Free

Enter a two's complement word and this converter rewrites it in signed magnitude form with the same number of bits: one sign bit followed by the absolute value.

How to use the Binary Signed magnitude Converter tool

  1. Enter the bits in the Two's complement binary word box, with leading zeros or ones to show the full width.
  2. Select Convert. The tool reads the signed value at that width and re-encodes it.
  3. Read the signed magnitude word in the Result box. The first bit is the sign and the remaining bits are the magnitude.
  4. Select Copy to take the result, or Example to load the 8-bit sample 11010111.

Signed magnitude compared with two's complement

Signed magnitude is the notation closest to how people write numbers. The leftmost bit is the sign, 0 for plus and 1 for minus, and the other bits hold the absolute value as plain binary. Negating a number means flipping one bit.

Two's complement stores a negative value as 2^n minus its magnitude, so the bits of -41 look nothing like the bits of +41. For zero and positive values the two notations are identical, and the converter returns them unchanged. Only words with a leading 1 are rewritten.

Worked example: converting 11010111

The sample word starts with 1, so it is negative. To find the magnitude, invert the bits to get 00101000 and add one to get 00101001, which is 41. The value is therefore -41.

Signed magnitude at 8 bits has 7 bits for the absolute value. Forty-one in 7 bits is 0101001, and with the sign bit in front the result is 10101001.

11010111  ->  10101001   (-41)
11111111  ->  10000001   (-1)
00101001  ->  00101001   (+41)
1111 1111 1101 0111  ->  1000000000101001   (-41 at 16 bits)

The value that does not fit

An n-bit two's complement word reaches from -2^(n-1) to 2^(n-1) - 1. Signed magnitude at the same width stops at -(2^(n-1) - 1), because one pattern is spent on a second zero. The most negative two's complement value therefore has no signed magnitude form.

Enter 10000000, which is -128, and the tool answers: This value does not fit in signed magnitude at the input width. The same applies to 1000 at 4 bits and to the single bit 1. Widen the word by sign extension, for example 1111111110000000, and the conversion succeeds.

Input handling and where the format appears

The width is the number of bits you enter, up to 65,536. Whitespace between groups is ignored and one 0b prefix at the start is allowed. Zero always converts to all zeros, so the tool never produces the negative zero pattern.

Signed magnitude is how IEEE 754 floating point stores its sign, and it shows up in some sensor and converter chips that report a direction bit plus a size. Translating between that layout and the two's complement integers a CPU works with is the usual reason to need this conversion.

Frequently asked questions

What is signed magnitude representation?

It is a way to write signed integers where the first bit is the sign and the rest is the absolute value in ordinary binary. In 8 bits, +5 is 00000101 and -5 is 10000101.

Why does 10000000 give an error?

In 8-bit two's complement that pattern is -128. Signed magnitude with 8 bits only has 7 magnitude bits, so its limit is -127. The tool reports that the value does not fit instead of returning a wrong word.

Do positive numbers change when converted?

No. When the leading bit is 0, both notations store the value as plain binary, so 00101001 comes back as 00101001. Only negative inputs get a new bit pattern.

How do I convert signed magnitude back to two's complement?

Use the Signed magnitude to Binary tool on this site. It takes the sign bit and magnitude and returns the two's complement word at the same width, so 10101001 becomes 11010111 again.

How does the converter know the word size?

It counts the digits you type. 1111 is a 4-bit word holding -1 and converts to 1001, while 00001111 is an 8-bit word holding +15 and stays the same. Always enter every bit of the word.

Related tools