Objectives

Students will be able to:

  • convert from hexadecimal to decimal.
  • understand the purpose of a Media Access Control (MAC) address.
  • understand that hexadecimal is a number system commonly used in low-level programming languages such as machine code or assembly language.

Practical Hexadecimal


Computing uses big numbers. Think about HTML color codes. 0x3DE401. If we express this in decimal we get 405606510. If we express the same number in binary we get 0011110111100100000000012.

So, for human computer programmers, hexadecimal is a very convenient form of representing binary numbers - the 1s and 0s that computers understand.

Here we will look at some practical examples of hexadecimal usage:

Media Access Control (MAC) addresses

recommended resource

Everytime you connect to the Internet, your device is assigned an IP (Internet Protocol) address. This can be an IPv4 address which uses 4 bytes and is written in the form 203.113.131.3 for example. This address identifies the location of your device on the Internet, allowing the device to be found when data is sent to it. The IP address assigned to your device can change. For example, if you go to Starbucks and use the available wifi, your device will be assigned a different IP address than the one you use at home.

Every device also has a MAC (Media Access Control) address. This identifies the actual device. It never changes. Here is a sample MAC Address:

E4-B3-18-8D-55-04

It is a 6-byte address and is represented using hexadecimal - remember, a byte is 8 bits and can be represented by 2 hexadecimal numbers.

TASK

What is the MAC address of your computer? Write it down in binary form.

Low Level programming Languages

recommended resource

Think about programming languages you are familiar with - Javascript, Python, Java, Ruby. These languages are close to human language. They use words like for, while and repeat. These are high level programming languages.

Low-level programming languages also exist and are necessary for writing specific code for hardware devices like your CPU.

For example, an Intel engineer programming the latest chip will need to use Assembly Language, a low level programming language.

To access specific memory addresses on the chip, the engineer will need to know which addresses to use.

To make it a little easier for the engineer to work with these addresses, Assembly Language presents them in hexadecimal format, rather than binary.

Here is an example of Assembly Language...

Can you convert these hexadecimal numbers to binary?

  • 1416
  • c416
  • 38716
  • ffff16
  • b7f5ca16

   Task

Go to boxy-svg and create an image of the device that is controlled by a microprocessor/register system in the last lesson.

Restriction: only use these colors:

Food For Thought

So... 8 bits is a byte of information and 4 bits is a nibble! Colors are represented using 3 bytes of data, one byte representing the red component, one byte representing the blue component and one byte representing the green component.

Hexadecimal is used to represent color information. A nibble (4 bits) can represent every hexadecimal symbol, from 0000 (0) to 1111 (F). So, 2 hexadecimal symbols represent 1 byte of information! In Photoshop, when you see the color code 0C1FDD 0C represents the red component (or channel), 1F represents the green channel and DD represents the blue channel - an RGB color code!

Homework




Tags

color decimal binary rgb hexadecimal base-2 red byte base-10 green bit base-16 blue nibble


SUBSCRIBE

Join my mailing list to receive updates on the latest blog posts and other things.