Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, How Integers and Floats Work! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

panel 1: let’s talk about how to write binary data

one way: binary

01111111 11111111 11111111
it’s easy to see the bits…

1010110110101001010
but it’s hard to read a lot of them

another way: base 10
83888607
but I have NO IDEA how many bits that is

panel 2: now the best way to write binary data: base 16!

It’s short AND maps well to bits!
7fffff
Every hexadecimal digit represents 4 bits. So 1 byte (8 bits) is always 2 hexadecimal digits.

panel 3: there are 16 hex digits: 0 → f

| hex | decimal | binary |
| 0   | 0       | 0000   |
| 1   | 1       | 0001   |
| 2   | 2       | 0010   |
| 3   | 3       | 0011   |
| 4   | 4       | 0100   |
| 5   | 5       | 0101   |
| 6   | 6       | 0110   |
| 7   | 7       | 0111   |
| 8   | 8       | 1000   |
| 9   | 9       | 1001   |
| a   | 10      | 1010   |
| b   | 11      | 1011   |
| c   | 12      | 1100   |
| d   | 13      | 1101   |
| e   | 14      | 1110   |
| f   | 15      | 1111   |

panel 4: 0x means it’s hex

In many languages, the 0x prefix lets you write numbers in hexadecimal.
For example, in C:
0x20 == 32 (base 16)
0b10100 20 (base 2)
061 == 49 (base 8)
be careful: the 0 prefix meaning “base 8” can really trip you up!

panel 5: things hexadecimal is used for

color codes! (e.g. #FF00FF)
memory addresses!
hashes! (like git commit IDs)
displaying binary data! (like with hexdump)

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)