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
Sign bit
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!
{{Refimprove|date=December 2009}} In [[computer science]], the '''sign bit''' is a [[bit]] in a [[signed number representation]] that indicates the [[sign (mathematics)|sign]] of a number. Although only [[signedness|signed]] numeric data types have a sign bit, it is invariably located in the [[most significant bit]] position,<ref name=":0">{{Cite web |title=Intelยฎ 64 and IA-32 Architectures Software Developer's Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4 |url=https://www.intel.com/content/www/us/en/content-details/782158/intel-64-and-ia-32-architectures-software-developer-s-manual-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4.html |access-date=2024-03-13 |website=Intel}}</ref> so the term may be used interchangeably with "most significant bit" in some contexts. Almost always, if the sign bit is 0, the number is non-negative (positive or zero).<ref name=":0" /> If the sign bit is 1 then the number is negative. Formats other than [[two's complement]] integers allow a [[signed zero]]: distinct "positive zero" and "negative zero" representations, the latter of which does not correspond to the mathematical concept of a [[negative number]]. When using a complement representation, to convert a signed number to a wider format the additional bits must be filled with copies of the sign bit in order to preserve its numerical value,<ref name="Bryant" />{{Rp|61โ62}} a process called ''[[sign extension]]'' or ''sign propagation''.<ref>{{Cite web |url=http://www.adrc.com/glossary/s1.html |title=Data Dictionary (Glossary and Algorithms) |website=Adroit Data Recovery Centre Pte Ltd |access-date=2014-12-15 |archive-date=2017-04-19 |archive-url=https://web.archive.org/web/20170419101741/http://www.adrc.com/glossary/s1.html |url-status=dead }}</ref> == Sign bit weight in Two's complement == {| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;" |+ !Bits !Value using Two's complement |- | {{Mono|'''0'''000}} | 0 |- | {{Mono|'''0'''001}} | 1 |- | {{Mono|'''0'''111}} | 7 |- | {{Mono|'''1'''000}} | โ8 |- | {{Mono|'''1'''001}} | โ7 |- | {{Mono|'''1'''111}} | โ1 |} [[Two's complement]] is by far the most common format for signed integers. In Two's complement, the sign bit has the weight {{Math|-2<sup>w-1</sup>}} where w is equal to the bits position in the number.<ref name=":0" /> With an 8-bit integer, the sign bit would have the value of {{Math|-2<sup>'''8'''-1</sup>}}, or -128. Due to this value being larger than all the other bits combined, having this bit set would ultimately make the number negative, thus changing the sign. == Sign bit weight in Ones' complement == {| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;" |+ !Bits !Value using One's complement |- | {{Mono|'''0'''000}} | 0 |- | {{Mono|'''0'''001}} | 1 |- | {{Mono|'''0'''111}} | 7 |- | {{Mono|'''1'''000}} | โ7 |- | {{Mono|'''1'''001}} | โ6 |- | {{Mono|'''1'''111}} | โ0 |} [[Ones' complement]] is similar to Two's Complement, but the sign bit has the weight {{Math|-(2<sup>w-1</sup> +1)}} where w is equal to the bits position in the number.{{Fact|date=March 2024}} With an 8-bit integer, the sign bit would have a value of {{Math|-(2<sup>'''8'''-1</sup> +1)}}, or -127. This allows for [[Signed zero|two types of zero]]: positive and negative, which is not possible with Two's complement. == Sign bit in sign magnitude integers == {| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;" |+ !Bits !Value using sign magnitude |- | {{Mono|'''0'''000}} | 0 |- | {{Mono|'''0'''001}} | 1 |- | {{Mono|'''0'''111}} | 7 |- | {{Mono|'''1'''000}} | โ0 |- | {{Mono|'''1'''001}} | โ1 |- | {{Mono|'''1'''111}} | โ7 |} Using [[sign magnitude]], the sign bit directly determines the sign. If the sign bit is 0, the number is positive; if the sign bit is 1, the number is negative.<ref name="Bryant" />{{Rp|52โ54}} Similarly with Ones' Complement, this allows for both a positive and a negative zero. == Sign bit in floating-point numbers == [[Floating-point arithmetic|Floating-point]] numbers, such as [[IEEE floating point|IEEE format]], [[IBM hexadecimal floating-point|IBM format]], [[VAX]] format, and even the format used by the Zuse [[Z1 (computer)|Z1]] and [[Z3 (computer)|Z3]] use a [[Sign and magnitude]] representation.{{Fact|date=April 2024}} ==References== {{reflist|refs= <ref name=Bryant>{{cite book |last1=Bryant |first1=Randal E. |last2=O'Hallaron |first2=David R. |title=Computer Systems: a Programmer's Perspective |year=2003 |publisher= Prentice Hall |location=Upper Saddle River, New Jersey |isbn=0-13-034074-X |chapter=Chapter 2: Representing and Manipulating Information}}</ref> }} {{DEFAULTSORT:Sign Bit}} [[Category:Binary arithmetic]] [[Category:Computer arithmetic]] [[Category:Sign (mathematics)]] {{Comp-sci-stub}}
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)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Comp-sci-stub
(
edit
)
Template:Fact
(
edit
)
Template:Math
(
edit
)
Template:Mono
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Rp
(
edit
)