Hexadecimal Numbers (2024)

Introduction

So far, we have looked at two number systems – base 2 (binary) and base 10 (decimal).

Another common number system used in Computer Science is base 16, otherwise known as hexadecimal, or hex for short.

In this lesson, we’ll learn about:

  1. What hexadecimal notation is.
  2. How to convert numbers from decimal to hexadecimal.
  3. How to convert numbers from hexadecimal to decimal.
  4. How to convert numbers from binary to hexadecimal.
  5. How to convert numbers from hexadecimal to binary.

What is Hexadecimal Notation?

Hexadecimal notation is a numbering system like binary and decimal, but everything goes up in multiples of 16.

However, because our decimal numbering system only goes from 0-9, we use the letters A-F to represent the remaining numbers.

DecimalHex Value
00
11
22
33
44
55
66
77
DecimalHex Value
88
99
10A
11B
12C
13D
14E
15F

Hexadecimal Numbers (2)

What is Hexadecimal Notation?

Just like you did with binary, the best way to get this right is to write down your Hex table before you start.

DecimalHex Value
00
11
22
33
44
55
66
77
DecimalHex Value
88
99
10A
11B
12C
13D
14E
15F

So, in hexadecimal, the number 6 is 6, just like decimal, but the number 14 is E.

Hexadecimal Numbers (3)

How to Convert Decimal to Hex

To find out the hex value of a decimal number we follow a similar process to working out the binary.

The difference between binary and hex conversions is that now we have to work out how many TIMES the column number will fit into our desired number.

Remember, with binary, each number to the left increases in multiples of 2. However, with hexadecimal, it increases by multiples of 16.

So, our columns are as follows:

4096256161

Hexadecimal Numbers (4)

Worked Example 1

Let’s work out the hex value for the decimal number 20.

Just like converting to binary, we ask similar questions and follow a similar process:

Will 4096 fit into 20?

No, so we don’t have any of these, so we put a 0 in the 4096 column.

4096256161
0

Will 256 fit into 20?

No, so we don’t have any of these, so we put a 0 in the 256 column.

4096256161
00

Hexadecimal Numbers (5)

Worked Example 1

Will 16 fit into 20?

Yes. How many times? 1 – so we put 1 in the 16 column.

4096256161
001

Now we have to take 16 away from 20. 20 – 16 = 4.

Will 1 fit into 4?

Yes. How many times? 4 – so we put 4 in the 1 column.

4096256161
0014

So, the hex value for 20 is 14 (and you say it as ONE–FOUR).

Don’t worry if that’s a bit confusing – let’s try another example with a larger number.

Hexadecimal Numbers (6)

Worked Example 2

Let’s work out the hex value for the decimal number 109.

Will 4096 fit into 109?

No, so we don’t have any of these, so we put a 0 in the 4096 column.

4096256161
0

Will 256 fit into 109?

No, so we don’t have any of these, so we put a 0 in the 256 column.

4096256161
00

Hexadecimal Numbers (7)

Worked Example 2

Will 16 fit into 109?

Yes. How many times? 6 – so we put 6 in the 16 column.

4096256161
006

6 x 16 is 96, so we have to take 96 away from 109. 109 – 96 = 13.

Will 1 fit into 13?

Yes. How many times? 13, of course. But what is the hex code for 13? Using the table near the start of this lesson, we can see that it is D.

So, we put D into the 1 column.

4096256161
006D

So, the hex value for 109 is 6D.

Hexadecimal Numbers (8)

Worked Example 3

Let’s try one last number. A really big one this time. Let’s try 5078.

Will 4096 fit into 5078?

Yes. How many times? 1 – so we put 1 in the 4096 column.

4096256161
1

Now we have to take 4096 away from 5078. 4096 – 5078 = 982.

Will 256 fit into 982?

Yes. How many times? 3 – so we put 3 in the 256 column.

4096256161
13

3 x 256 is 768, so we have to take 768 away from 982. 982 – 768 = 214.

Hexadecimal Numbers (9)

Worked Example 3

Will 16 fit into 214?

Yes. How many times? 13 – but what is the hex code for 13? Using the table near the start of this lesson, we can see that it is D.

So, we put D in the 16 column.

4096256161
13D

13 x 16 is 208, so we have to take 208 away from 214. 214 – 208 = 6.

Will 1 fit into 6?

Yes. How many times? 6 – so we put 6 in the 1 column.

4096256161
13D6

So, the hex value for 5078 is 13D6.

Hexadecimal Numbers (10)

How to Convert Hex to Decimal

Converting from hexadecimal to decimal is straightforward. All we need is our hex table from the beginning of this lesson.

Let’s look at the example below:

4096256161
10D9

We have nothing in the 4096 and the 256 columns, so we can leave those alone.

We have D in the 16 column. We can see from our hex table that D is the hex value for 13. So, we need to multiply 13 x 16, which gives us 208.

In the 1’s column, we have 9, which we don’t need to do anything to.

Now, we just need to add these numbers together. 208 + 9 = 217.

So, the decimal value for D9 is 217.

Hexadecimal Numbers (11)

How to Convert Binary to Hex

In a previous lesson, we learned that a nibble is 4 bits. The smallest number we can store in 4 bits is 0.

8421
0000

The largest number we can store in 4 bits is 15.

8421
1111

In hex, each column goes from 0 – 15. Therefore, each column can be represented as a nibble.

Let’s look at how we do this.

Hexadecimal Numbers (12)

Worked Example 1

Let’s take the binary number 100011.

What we need to do is turn these 6 bits into two 4-bit nibbles.

This means we’ll need to add two 0s to the left side of this number to give us 7 bits in total.

This gives us: 00100011.

Now, let’s split this into two separate nibbles and treat them as two separate binary numbers.

8421
0010
8421
0011

Hexadecimal Numbers (13)

Worked Example 1

Let’s take the binary number 100011.

We can then convert these two numbers easily into hexadecimal by adding up the column values that have 1s in them.

This is just like we do in binary to decimal conversion.

8421
0010
8421
0011

The first number is equal to 2.

The second number is equal to 3.

So, the binary number 100011 in hexadecimal is 23.

Note, that’s TWO-THREE, not twenty-three.

Hexadecimal Numbers (14)

Worked Example 2

Consider the number 11101010.

This is already 8 bits, so we can straightaway split it into our two nibbles.

8421
1110
8421
1010

We can now convert these two nibbles into their hexadecimal values.

The first number is equal to 14, which in hexadecimal is E.

The second number is equal to 10, which in hexadecimal is A.

So, the binary number 11101010 in hexadecimal is EA.

Hexadecimal Numbers (15)

How to Convert Hex to Binary

Yet again, we need to understand that each hex column can be split into a binary nibble – a number between 0 and 15.

Let’s say you have a hex number. We’ll use 4D.

What we need to do is recognise that these are two individual nibbles, and so we work out these separately.

8421
0100
8421
1011

Then, we simply stick them together.

1286432168421
01001011

So, the hex number 4D is 01001011 in binary.

Hexadecimal Numbers (16)

Lesson Summary

Hex notation involves columns that are multiples of 16.

Hex is used to make long binary sequences easier to read.

The numbers 10 – 15 are represented by the letters A – F in hex.

To convert from decimal to hex we need to work out how many TIMES the column number will fit into our desired number.

To convert from hex to decimal, we multiply the number in each column by the column value.

Converting to and from binary involves treating each column as a nibble.

Hexadecimal Numbers (17)

Hexadecimal Numbers (2024)
Top Articles
7 Surprising Reasons Why Cooking at Home is a Recipe for Better Health
Azure Subscription Types 2023
Exclusive: Baby Alien Fan Bus Leaked - Get the Inside Scoop! - Nick Lachey
Hotels Near 625 Smith Avenue Nashville Tn 37203
Mopaga Game
New Slayer Boss - The Araxyte
Gore Videos Uncensored
Truist Drive Through Hours
B67 Bus Time
Cube Combination Wiki Roblox
Comenity Credit Card Guide 2024: Things To Know And Alternatives
Hartford Healthcare Employee Tools
I Touch and Day Spa II
Wicked Local Plymouth Police Log 2022
U Break It Near Me
MLB power rankings: Red-hot Chicago Cubs power into September, NL wild-card race
Long Island Jobs Craigslist
ABCproxy | World-Leading Provider of Residential IP Proxies
Highmark Wholecare Otc Store
8005607994
How Long After Dayquil Can I Take Benadryl
Engineering Beauties Chapter 1
Ceramic tiles vs vitrified tiles: Which one should you choose? - Building And Interiors
California Online Traffic School
Kirsten Hatfield Crime Junkie
Discord Nuker Bot Invite
Sorrento Gourmet Pizza Goshen Photos
Craigslist Dubuque Iowa Pets
Gen 50 Kjv
Best Town Hall 11
Mini-Mental State Examination (MMSE) – Strokengine
Uno Fall 2023 Calendar
Transformers Movie Wiki
Golden Tickets
JD Power's top airlines in 2024, ranked - The Points Guy
Great Clips On Alameda
Western Gold Gateway
Whitehall Preparatory And Fitness Academy Calendar
How To Get Soul Reaper Knife In Critical Legends
Eastern New Mexico News Obituaries
Hindilinks4U Bollywood Action Movies
Michael Jordan: A timeline of the NBA legend
Husker Football
Craigslist Central Il
Payrollservers.us Webclock
Natasha Tosini Bikini
Lorton Transfer Station
Displacer Cub – 5th Edition SRD
18443168434
Game Akin To Bingo Nyt
Bunbrat
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 5967

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.