Jump to content

Sign bit

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Vadmium (talk | contribs) at 06:54, 13 October 2012 (WP:Easter egg wrapped in a formula; these don’t need to be linked anyway). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, the sign bit is a bit in a binary computer numbering format that indicates the sign of a number. Only signed numeric data types have a sign bit, and its place is usually the leftmost, where the most significant bit in unsigned integers resides. Floating point numbers in IEEE format are always signed, with the sign bit in the leftmost position. Typically if the sign bit is 1 then the number is negative (in the case of two's complement integers) or non-positive (for ones' complement integers, sign-and-magnitude integers, and floating point numbers), while 0 indicates a non-negative number.

In the two's complement signed number representation, the sign bit has the weight −2w−1 where w is the number of bits. In the ones' complement representation, the most negative value is 1 − 2w−1, but there are two representations of zero, one for each value of the sign bit. In a sign-and-magnitude representation of numbers, the value of the sign bit determines whether the numerical value is positive or negative. [1]

When an 8-bit value is added to a 16-bit value using signed arithmetic, the processor unit propagates the sign bit through the high order half of the 16-bit register holding the 8-bit value – a process called sign extension or sign propagation.[2] The process of sign extension is used whenever a smaller signed data type needs to be converted into a larger signed data type while still retaining its original numerical value. [3]

References

  1. ^ Bryant, Randal; O'Hallaron, David (2003). "2". Computer Systems: a Programmer's Perspective. Upper Saddle River, New Jersey: Prentice Hall. pp. 52–54. ISBN 0-13-034074-X.
  2. ^ http://www.adrc.net/data-dictionary/s1.htm
  3. ^ Bryant, Randal; O'Hallaron, David (2003). "2". Computer Systems: a Programmer's Perspective. Upper Saddle River, New Jersey: Prentice Hall. pp. 61–62. ISBN 0-13-034074-X.