Understanding memory, bits, bytes, addresses and hexadecimal
Memory can be understood as a space that is composed of bits. Each time something happens in a program you write or get something out of memory by manipulating bits.

The hardware then takes what is in memory and communicates with the machine. In most hardwares, the memory is split between different things like drawing pixels, playing sounds, changing the state of the application.

Since manipulating bits is complicated, bits are combined together into bytes. And to ease their manipulation, bytes are identified by a number called an address.

What is binary
When you write numbers, you use the decimal system which is made from 10 numerals:
0
1
2
3
4
5
6
7
8
9
But what happens when we don't have a numeral for the next number? We move the first digit and the first digit takes a new meaning.
0
1
2
3
.
8
9
10
11
12
But computers only understand 0
and 1
, so how do you translate binary into numbers?
To write other numerals from 2
to 9
, you have to compose those numerals with a set of 0
and 1
. For example, in binary, to write 2
, you write 10
:
Numeral - Binary
0 - 0
1 - 1
2 - 10
3 - 11
But we are now out of digits to create 3
. So just like with numerals, we add a new digit:
Numeral - Binary
0 - 0
1 - 1
2 - 10
3 - 11
4 - 100
5 - 101
6 - 110
7 - 111
And it continues for 8
:
Numeral - Binary
0 - 0
1 - 1
2 - 10
3 - 11
4 - 100
5 - 101
6 - 110
7 - 111
8 - 1000
The next set of numerals will be at 16
(8 + 8
) and then at 32 (16 + 16
) and so on.
That means that in a byte, which is made of 8 bits who are themselves binaries (0 and 1), the maximum number you can write is 255
, composed by writing 11111111
.
Therefore, a byte contains only 256 numerals.

Hexadecimal
Hexadecimal is another type of numerals used in programming. Instead of going from 0
to 9
, hexadecimal goes from 0
to 15
without adding a 1
numeral to count over 9
.
Instead, hexadecimal uses letters, from A
to F
as new digits.
Numeral - Binary - Hexadecimal
0 - 0 - 1
1 - 1 - 2
2 - 10 - 3
3 - 11 - 3
4 - 100 - 4
5 - 101 - 5
6 - 110 - 6
7 - 111 - 7
8 - 1000 - 8
9 - - 9
10 - - A
11 - - B
12 - - C
13 - - D
14 - - E
15 - - F
When hexadecimal goes beyond 15, it uses binaries again.
Numeral - Binary - Hexadecimal
0 - 0 - 1
1 - 1 - 2
2 - 10 - 3
3 - 11 - 3
4 - 100 - 4
5 - 101 - 5
6 - 110 - 6
7 - 111 - 7
8 - 1000 - 8
9 - - 9
10 - - A
11 - - B
12 - - C
13 - - D
14 - - E
15 - - F
16 - - 10
17 - - 11
18 - - 12
The idea between hexadecimal is to be able to translate big numbers using only two digits. For example, FF
in hexadecimal means 255
digits.

Addresses can also be written in hexadecimal.
Credits
This page is a partial transcript of this video by Lazy Devs Academy. The captures are also made from the video.
Generated: March 3rd, 2023