remove non ascii whitespaces
This commit is contained in:
parent
598a10bc28
commit
5a6d6c4d13
117 changed files with 1928 additions and 1928 deletions
|
@ -10,14 +10,14 @@ Negative numbers are commonly represented in binary using two's complement.
|
|||
Two's complement of an integer number is achieved by:
|
||||
- Step 1: Start with the absolute value of the number.
|
||||
- Step 2: inverting (or flipping) all bits – changing every 0 to 1, and every 1 to 0;
|
||||
- Step 3: adding 1 to the entire inverted number, ignoring any overflow. Accounting for overflow will produce the wrong value for the result.
|
||||
- Step 3: adding 1 to the entire inverted number, ignoring any overflow. Accounting for overflow will produce the wrong value for the result.
|
||||
|
||||
For example, to calculate the decimal number **−6** in binary:
|
||||
- Step 1: _+6_ in decimal is _0110_ in binary; the leftmost significant bit (the first 0) is the sign (just _110_ in binary would be -2 in decimal).
|
||||
- Step 2: flip all bits in _0110_, giving _1001_.
|
||||
- Step 3: add the place value 1 to the flipped number _1001_, giving _1010_.
|
||||
For example, to calculate the decimal number **−6** in binary:
|
||||
- Step 1: _+6_ in decimal is _0110_ in binary; the leftmost significant bit (the first 0) is the sign (just _110_ in binary would be -2 in decimal).
|
||||
- Step 2: flip all bits in _0110_, giving _1001_.
|
||||
- Step 3: add the place value 1 to the flipped number _1001_, giving _1010_.
|
||||
|
||||
To verify that _1010_ indeed has a value of _−6_, add the place values together, but _subtract_ the sign value from the final calculation. Because the most significant value is the sign value, it must be subtracted to produce the correct result: **1010** = **−**(**1**×23) + (**0**×22) + (**1**×21) + (**0**×20) = **1**×−8 + **0** + **1**×2 + **0** = −6.
|
||||
To verify that _1010_ indeed has a value of _−6_, add the place values together, but _subtract_ the sign value from the final calculation. Because the most significant value is the sign value, it must be subtracted to produce the correct result: **1010** = **−**(**1**×23) + (**0**×22) + (**1**×21) + (**0**×20) = **1**×−8 + **0** + **1**×2 + **0** = −6.
|
||||
|
||||
| Bits: | 1 | 0 | 1 | 0 |
|
||||
| -------------------- | --------------- | ---------- | ---------- | ---------- |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue