init
This commit is contained in:
commit
c5cd492449
475 changed files with 27928 additions and 0 deletions
26
science/math/Binary System.md
Normal file
26
science/math/Binary System.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
obj: concept
|
||||
---
|
||||
# Binary System
|
||||
The base-2 numeral system is a positional notation with a radix of 2. Each digit is referred to as a bit, or binary digit. Because of its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used by almost all modern computers and computer-based devices, as a preferred system of use, over various other human techniques of communication, because of the simplicity of the language and the noise immunity in physical implementation.
|
||||
|
||||
Negative numbers are commonly represented in binary using two's complement.
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
| Bits: | 1 | 0 | 1 | 0 |
|
||||
| -------------------- | --------------- | ---------- | ---------- | ---------- |
|
||||
| Decimal bit value: | **−**8 | 4 | 2 | 1 |
|
||||
| Binary calculation: | **−**(**1**×23) | (**0**×22) | (**1**×21) | (**0**×20) |
|
||||
| Decimal calculation: | **−**(**1**×8) | **0** | **1**×2 | **0** |
|
Loading…
Add table
Add a link
Reference in a new issue