Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Signed number representations
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Sign–magnitude == {|class="wikitable" style="float:right; width: 20em; margin-left: 1em; text-align:center" |+ Eight-bit sign–magnitude |- ! Binary value ! Sign–magnitude interpretation ! Unsigned interpretation |- | 00000000 || 0 || 0 |- | 00000001 || 1 || 1 |- | ⋮ || ⋮ || ⋮ |- | 01111101 || 125 || 125 |- | 01111110 || 126 || 126 |- | 01111111 || 127 || 127 |- | 10000000 || −0 || 128 |- | 10000001 || −1 || 129 |- | 10000010 || −2 || 130 |- | ⋮ || ⋮ || ⋮ |- | 11111101 || −125 || 253 |- | 11111110 || −126 || 254 |- | 11111111 || −127 || 255 |} 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<sub>10</sub> to +127<sub>10</sub> can be represented once the sign bit (the eighth bit) is added. For example, −43<sub>10</sub> encoded in an eight-bit byte is '''1'''0101011 while 43<sub>10</sub> is '''0'''0101011. Using sign–magnitude representation has multiple consequences which makes them more intricate to implement:<ref name="cs315">{{cite web |last1=Bacon |first1=Jason W. |url=http://www.cs.uwm.edu/classes/cs315/Bacon/Lecture/HTML/ch04s11.html |title=Computer Science 315 Lecture Notes |access-date=21 February 2020 |date=2010–2011 |archive-date=14 February 2020 |archive-url=https://web.archive.org/web/20200214050150/http://www.cs.uwm.edu/classes/cs315/Bacon/Lecture/HTML/ch04s11.html |url-status=dead }}</ref> # 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 arithmetic|floating-point]] values.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)