No Login Data Private Local Save

Signed Magnitude Converter - Online Negative Binary Numbers

16
0
0
0

Signed Magnitude Converter

Convert between decimal integers and signed magnitude binary representation. Visualize the sign bit and magnitude bits.

Bit Width:
Decimal → Signed Magnitude

Enter a decimal integer to get its signed magnitude binary representation.

Range for 8-bit: −127 to +127
Enter a decimal number and click Convert
Signed Magnitude → Decimal

Enter a signed magnitude binary string to get its decimal value.

Enter a binary string and click Convert
Quick Examples:
Legend: Sign bit = 0 (positive) Sign bit = 1 (negative) Magnitude bit = 1 Magnitude bit = 0
Signed Magnitude Range by Bit Width
Bit Width Min Value Max Value Distinct Values Special Case
4-bit−7+715+0 (0000), −0 (1000)
8-bit−127+127255+0 (00000000), −0 (10000000)
16-bit−32,767+32,76765,535+0, −0
32-bit−2,147,483,647+2,147,483,6474,294,967,295+0, −0
Frequently Asked Questions

Signed magnitude is a method of encoding signed integers in binary. The most significant bit (MSB) serves as the sign bit: 0 indicates a positive number, and 1 indicates a negative number. The remaining bits represent the absolute value (magnitude) of the number. For example, in 8-bit signed magnitude, 00000101 = +5 and 10000101 = −5. This representation is intuitive for humans but has some drawbacks in hardware implementation, which is why modern computers typically use two's complement instead.

To convert a signed magnitude binary number to decimal: Step 1: Look at the leftmost bit (sign bit). If it's 0, the number is positive; if 1, the number is negative. Step 2: Take the remaining bits and convert them to decimal as a regular unsigned binary number (this is the magnitude). Step 3: Apply the sign from Step 1. For example, 10000101 → sign bit is 1 (negative), magnitude bits 0000101 = 5, so the result is −5. Use our converter above to practice!

To convert a decimal integer to signed magnitude: Step 1: Determine the sign — if the number is negative, the sign bit will be 1; if positive, 0. Step 2: Take the absolute value of the number and convert it to unsigned binary. Step 3: Pad the magnitude bits to fill (n−1) bits for an n-bit representation, then prepend the sign bit. For example, −5 in 8-bit: sign = 1, magnitude of 5 = 0000101 (7 bits), result = 10000101. Check the range first — our tool validates this automatically!

In signed magnitude, +0 is represented with a sign bit of 0 and all magnitude bits as 0 (e.g., 00000000 in 8-bit). −0 is represented with a sign bit of 1 and all magnitude bits as 0 (e.g., 10000000). This duplication occurs because the sign bit is independent of the magnitude — both represent zero mathematically, but have different binary encodings. This is one of the disadvantages of signed magnitude: it wastes one bit pattern and complicates arithmetic circuits. Two's complement avoids this by having only one zero.

For an n-bit signed magnitude representation, the range is [−(2n−1−1), +(2n−1−1)]. For example: 4-bit: −7 to +7, 8-bit: −127 to +127, 16-bit: −32,767 to +32,767, 32-bit: −2,147,483,647 to +2,147,483,647. The total number of distinct values is 2n−1 (due to the duplicate zero). Compare this with two's complement which has a range of [−2n−1, +2n−1−1] and 2n distinct values.

FeatureSigned MagnitudeTwo's Complement
Sign bitIndependent (1 = negative)Integrated (MSB has negative weight)
Zero representationTwo zeros (+0, −0)One zero
8-bit range−127 to +127−128 to +127
Hardware simplicityMore complex (separate sign handling)Simpler (unified addition)
UsageFloating-point (IEEE 754 mantissa sign)Integer arithmetic in modern CPUs
While signed magnitude is intuitive, two's complement dominates integer arithmetic because it simplifies addition/subtraction circuits. However, signed magnitude is used in IEEE 754 floating-point for the sign of the mantissa.

Advantages: (1) Intuitive and easy for humans to read — the sign bit clearly indicates positive or negative. (2) Simple to convert between binary and decimal — just separate the sign and magnitude. (3) Symmetric range around zero (e.g., −127 to +127).

Disadvantages: (1) Two representations of zero (+0 and −0), wasting one bit pattern. (2) Addition/subtraction requires separate handling of sign and magnitude, making hardware more complex. (3) Cannot represent −2n−1 (e.g., −128 in 8-bit is impossible in signed magnitude but valid in two's complement). (4) Requires end-around carry in some operations.

Although most integer arithmetic in modern CPUs uses two's complement, signed magnitude appears in: (1) IEEE 754 Floating-Point Standard: The sign bit of floating-point numbers (bit 31 in single-precision) uses signed magnitude — the mantissa and exponent are stored separately. (2) Some DSP applications where symmetric range is preferred. (3) Educational contexts — it's often the first signed binary representation taught because of its intuitive nature. (4) Certain analog-to-digital converters (ADCs) that output signed magnitude format.