Primary
Sign–Magnitude ○|Definition|1st|20251122011306-00-⌔
Signed number representations - Wikipedia#Sign–magnitude
Sign–magnitude
In the sign–magnitude representation, also called sign-and-magnitude or signed magnitude, a signed number is represented by the bit pattern corresponding to the sign of the number for the sign bit (often the most significant bit, set to 0 for a positive number and to 1 for a negative number), and the magnitude of the number (or absolute value) for the remaining bits. For example, in an eight-bit byte, only seven bits represent the magnitude, which can range from 0000000 (0) to 1111111 (127). Thus numbers ranging from −127 to +127 can be represented once the sign bit (the eighth bit) is added. For example, −43 encoded in an eight-bit byte is 1 0101011 while 43 is 0 0101011. Using sign–magnitude representation has multiple consequences which makes them more intricate to implement:1
- There are two ways to represent zero, 00000000 (0) and 10000000 (−0).
- Addition and subtraction require different behavior depending on the sign bit, whereas ones’complement can ignore the sign bit and just do an end-around carry, and two’s complement can ignore the sign bit and depend on the overflow behavior.
- Comparison also requires inspecting the sign bit, whereas in two’s complement, one can simply subtract the two numbers, and check if the outcome is positive or negative.
- The minimum negative number is −127, instead of −128 as in the case of two’s complement.
This approach is directly comparable to the common way of showing a sign (placing a ”+” or ”−” next to the number’s magnitude). Some early binary computers (e.g., IBM 7090) use this representation, perhaps because of its natural relation to common usage. Sign–magnitude is the most common way of representing the significand in floating-point values.
Printed 2026-06-28.
(echo:: @ ᯤ)
Link to original Footnotes
Bacon, Jason W. (2010–2011). “Computer Science 315 Lecture Notes”. Archived from the original on 14 February 2020. Retrieved 21 February 2020. ↩
Secondary
• • •