diff --git a/section_1/hex.md b/section_1/hex.md index 4883039..6c95ee3 100644 --- a/section_1/hex.md +++ b/section_1/hex.md @@ -3,49 +3,57 @@ Hex is only lightly covered here because there is a very good chance you are already familiar with the concept. -The TL;DR is: Hex is base sixteen. Hex is useful because being base 16, -each hex digit represents 4 bits and just two hex digits completely -indicates the 8 bits in a byte. Hex digits run from 0 through 9 and then -A through F. Example: decimal 255 is hex FF. +The TL;DR is: Hex is base sixteen. Hex is useful because 16 is 2 raised +to the power of 4. Each hex digit represents 4 bits. Just two hex digits +completely specify the 8 bits in a byte. Hex digits run from 0 through 9 +and then A through F. + +Example: decimal 255 is hex FF. ## Numbers in Base 10 -You already know that each digit in a base 10 number is added to a power -of 10. The first digit is added to 10 to the 0. The second digit is -added to 10 to the 1 and so on. +You already know that each digit in a base 10 number is multiplied by a +power of 10. The least significant digit is multiplied by 10 to the 0. +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 -### 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 -is added to 2 to the 1 and so on. - -### 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. +The digits of the fractional part of a floating point number are +multiplied with negative powers of 2. See [Section +2](../section_2/float/) for more detailed information. ## Number in Base 16 - Hexadecimal -Hex numbers work the same way as binary and decimal except there are -more than 10 values for each digit. We draft the letter A through F to -mean the values 10 through 15. +In decimal there are 10 values available for each digit. -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 -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 -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. +Goldilocks does not approve of octal. ## Printing Hex @@ -64,5 +72,5 @@ You can spell stuff with hex. | 8BADFOOD | Found for similar reasons but on Apple products | | DEADDEAD | Associated with the Blue Screen of Death | | F003BA11 | Used by undergraduates everywhere | -| COEDBABE | Used by misogynists everywhere | +| C0EDBABE | Used by misogynists everywhere | | B16B00B5 | Used by misogynists at Microsoft | diff --git a/section_1/hex.pdf b/section_1/hex.pdf index 8519f5b..4cadb61 100644 Binary files a/section_1/hex.pdf and b/section_1/hex.pdf differ