mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-21 02:26:59 +08:00
do not write while sleeping
This commit is contained in:
parent
8563514482
commit
21f3175578
2 changed files with 36 additions and 28 deletions
|
|
@ -3,49 +3,57 @@
|
||||||
Hex is only lightly covered here because there is a very good chance you
|
Hex is only lightly covered here because there is a very good chance you
|
||||||
are already familiar with the concept.
|
are already familiar with the concept.
|
||||||
|
|
||||||
The TL;DR is: Hex is base sixteen. Hex is useful because being base 16,
|
The TL;DR is: Hex is base sixteen. Hex is useful because 16 is 2 raised
|
||||||
each hex digit represents 4 bits and just two hex digits completely
|
to the power of 4. Each hex digit represents 4 bits. Just two hex digits
|
||||||
indicates the 8 bits in a byte. Hex digits run from 0 through 9 and then
|
completely specify the 8 bits in a byte. Hex digits run from 0 through 9
|
||||||
A through F. Example: decimal 255 is hex FF.
|
and then A through F.
|
||||||
|
|
||||||
|
Example: decimal 255 is hex FF.
|
||||||
|
|
||||||
## Numbers in Base 10
|
## Numbers in Base 10
|
||||||
|
|
||||||
You already know that each digit in a base 10 number is added to a power
|
You already know that each digit in a base 10 number is multiplied by a
|
||||||
of 10. The first digit is added to 10 to the 0. The second digit is
|
power of 10. The least significant digit is multiplied by 10 to the 0.
|
||||||
added to 10 to the 1 and so on.
|
The next least significant digit is multiplied to 10 to the 1 and so on.
|
||||||
|
|
||||||
|
Floating point numbers in decimal are multiplied by negative powers of
|
||||||
|
10.
|
||||||
|
|
||||||
|
The digits available to us are 0 through 9.
|
||||||
|
|
||||||
## Numbers in Base 2
|
## Numbers in Base 2
|
||||||
|
|
||||||
### Integers
|
Binary is the same thing except with powers of 2. The digits available
|
||||||
|
to us are 0 and 1.
|
||||||
|
|
||||||
Binary is the same thing except with powers of 2.
|
The first (least significant) digit is multiplied by 2 to the 0. The
|
||||||
|
second is multiplied by 2 to the 1 and so on.
|
||||||
|
|
||||||
The first (least significant) digit is added to 2 to the 0. The second
|
The digits of the fractional part of a floating point number are
|
||||||
is added to 2 to the 1 and so on.
|
multiplied with negative powers of 2. See [Section
|
||||||
|
2](../section_2/float/) for more detailed information.
|
||||||
### Floats
|
|
||||||
|
|
||||||
Floats are more complicated but in rough terms the digits are raised to
|
|
||||||
negative powers of 2. See [Section 2](../section_2/float/) for more
|
|
||||||
detailed information.
|
|
||||||
|
|
||||||
## Number in Base 16 - Hexadecimal
|
## Number in Base 16 - Hexadecimal
|
||||||
|
|
||||||
Hex numbers work the same way as binary and decimal except there are
|
In decimal there are 10 values available for each digit.
|
||||||
more than 10 values for each digit. We draft the letter A through F to
|
|
||||||
mean the values 10 through 15.
|
|
||||||
|
|
||||||
Hex is a handy way of describing binary numbers with much less effort.
|
In binary there are 2 values available for each digit.
|
||||||
|
|
||||||
|
Hex numbers work the same way as binary and decimal except there are 16
|
||||||
|
values for each digit. We draft the letters A through F to mean the
|
||||||
|
values 10 through 15.
|
||||||
|
|
||||||
|
Hex is a handy way of describing binary numbers with much less effort
|
||||||
|
because each hex digit encodes 4 binary digits.
|
||||||
|
|
||||||
## Octal - Numbers in Base 8
|
## Octal - Numbers in Base 8
|
||||||
|
|
||||||
We don't speak of such things.
|
Base 8, or octal, is used far less than hex in CS because base 8 doesn't
|
||||||
|
naturally encode into a powers-of-two centric digital world. Two hex
|
||||||
|
digits perfectly fit in a byte but two octal digits are 6 bits... too
|
||||||
|
small. Three octal digits are 9 bits... too big.
|
||||||
|
|
||||||
More seriously, base 8, or octal, is used far less than hex (permission
|
Goldilocks does not approve of octal.
|
||||||
bits in Linux is one place where it is used) in CS because it doesn't
|
|
||||||
naturally encode into a single byte. Two hex digits perfectly since in a
|
|
||||||
byte but two octal digits is 6 bits... too small and three octal digits
|
|
||||||
is 9 bits... too big. Goldilocks does not approve.
|
|
||||||
|
|
||||||
## Printing Hex
|
## Printing Hex
|
||||||
|
|
||||||
|
|
@ -64,5 +72,5 @@ You can spell stuff with hex.
|
||||||
| 8BADFOOD | Found for similar reasons but on Apple products |
|
| 8BADFOOD | Found for similar reasons but on Apple products |
|
||||||
| DEADDEAD | Associated with the Blue Screen of Death |
|
| DEADDEAD | Associated with the Blue Screen of Death |
|
||||||
| F003BA11 | Used by undergraduates everywhere |
|
| F003BA11 | Used by undergraduates everywhere |
|
||||||
| COEDBABE | Used by misogynists everywhere |
|
| C0EDBABE | Used by misogynists everywhere |
|
||||||
| B16B00B5 | Used by misogynists at Microsoft |
|
| B16B00B5 | Used by misogynists at Microsoft |
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue