Bifalgorithm post · Brisk · Chapter 1

Why is hexadecimal used in computer science, and what do its digits represent?

Why is hexadecimal used in computer science, and what do its digits represent? (Brisk · Chapter 1) — "Now objectively speaking, it turns out that ten is a pret…

Ideas in this flowchart

  • La base hexadecimal (base 16) es un sistema numérico especialmente útil en informática.
  • La base diez es una elección algo extraña: solo es divisible por 2 y 5 y no es un cuadrado perfecto.
  • En informática resulta muy conveniente utilizar bases que sean potencias de dos.
  • El octal, o base 8, fue una elección común en los primeros tiempos de la informática, pero es menos conveniente que el hexadecimal.
  • El hexadecimal aparece con frecuencia en hardware, sistemas operativos, controladores de dispositivos y máscaras de bits.
  • La base 16 necesita dieciséis símbolos distintos para representar sus dígitos.
  • Además de los dígitos del 0 al 9, utiliza las letras A hasta F.
  • En hexadecimal, A representa diez, B once, C doce, D trece, E catorce y F quince.
  • Los valores posicionales son potencias de 16: 16⁰, 16¹, 16², 16³ y sucesivas.
  • Por ejemplo, 72E3₁₆ equivale a 7 × 4096 + 2 × 256 + 14 × 16 + 3, es decir, 29 411₁₀.
  • El valor máximo de un dígito hexadecimal es F; con dos dígitos es FF y con tres es FFF.
  • Al contar en hexadecimal, los dígitos avanzan igual que en decimal, pero se pasa a la siguiente posición después de F.
Feed/

Why is hexadecimal used in computer science, and what do its digits represent?

Channel

Brisk

1 page

"Now objectively speaking, it turns out that ten is a pretty weird base too. I know it doesn’t seem like it, but that’s only because we’re so used to it. Really, if you’re repeatedly adding little circles to a drawing, ten is a funny place to decide to draw the line and go to more digits. It’s only divisible by 2 and 5 (of all things), it’s not a perfect square, and all this makes it kind of an awkward choice. In computer science, it turns out to be very (very) convenient to use a base that is a power of two. This means a base that is “two-to-the-something.” In earlier computing days, octal (base 8) was a common choice. But for various reasons, that turns out to be less convenient than using base 16, or hexadecimal. Any time you’re working with hardware, operating systems, device drivers, bit masks, or anything else low level, you’ll encounter numbers written in base 16 a heck of a lot. So let’s study this particular base in some detail. Base 16 will need sixteen digits, of course. Unfortunately, we ten-fingered people have only invented ten symbols that are obviously numerical: the digits 0 through 9. So what do we do for the other six? It turns out that the originators of this system took perhaps the most obvious approach: repurposing the letters of the alphabet. So we add the “digits” A through F (sometimes written as capitals, sometimes in lower-case) to our set of symbols. These, then, are the quantities that each individual digit represents: 0 zero, 1 one, 2 two, 3 three, 4 four, 5 five, 6 six, 7 seven, 8 eight, 9 nine, A ten, B eleven, C twelve, D thirteen, E fourteen, F fifteen. The inventors of hexadecimal notation didn’t have to use the alphabet, of course; they could have chosen a star for ten, a square for eleven, a happy face for twelve, etc., but that wouldn’t have been very easy to type. So we’re stuck with the letters, for better or for worse. Practice staring at that letter A and saying the word “ten.” Because that’s what it means. In hexadecimal, the sequence of digits 10 does not mean “ten.” It means “sixteen.” Those are the symbols. What are the place values? Well, they are (from the right) the 16^0’s place, the 16^1’s place, the 16^2’s place, and so on. Written decimally, those work out to be the 1’s place, the 16’s place, the 256’s place, the 4096’s place, and so on. Again, those numbers seem strange only because when they are written decimally they don’t come out very “round.” The value of a number like 72E3 is computed as: 72E3_16 = 7 × 4096_10 + 2 × 256_10 + 14 × 16_10 + 3 × 1_10 = 29,411_10. Notice we treated the “E” just like another digit, which it is. We also called 72E3 “a number,” which it is. Get used to the idea that numbers — totally legitimate numbers — can have letters for some of their digits. In hexadecimal, what’s the highest value that can fit in one digit? Answer: F (which is fifteen.) What’s the highest that can fit in two digits? FF (which is two hundred fifty-five.) What about three digits? FFF (which is sixty-five thousand five hundred thirty-five.) And so on. If you count in hexadecimal, you do the same thing as in decimal, only you “roll over the odometer” when you get to F, not when you get to 9."

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.