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
Two's complement
(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!
==Converting from two's complement representation== A two's-complement number system encodes positive and negative numbers in a binary number representation. The weight of each bit is a power of two, except for the [[most significant bit]], whose weight is the negative of the corresponding power of two. The value {{mvar|w}} of an {{mvar|N}}-bit integer <math>a_{N-1} a_{N-2} \dots a_0</math> is given by the following formula: <math display="block">w = -a_{N-1} 2^{N-1} + \sum_{i=0}^{N-2} a_i 2^i</math> The most significant bit determines the sign of the number and is sometimes called the [[sign bit]]. Unlike in [[sign-and-magnitude]] representation, the sign bit also has the weight {{math|β(2<sup>''N''βββ1</sup>)}} shown above. Using {{mvar|N}} bits, all integers from {{math|β(2<sup>''N''βββ1</sup>)}} to {{math|2<sup>''N''βββ1</sup> β 1}} can be represented.
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)