Module_08

Module 8: Binary and Hexadecimal values of color

What you will learn:

  • What is a base?

  • What are the characteristics of a base?

  • How many digits can a base have?

  • How to utilize a base using addition

  • Using hexadecimal to select colors


What is a base?

Americans are used to using Base 10 (decimal system) for calculations and counting. Computers use 1s and 0s which is Base 2. We want to find out what the rules are as we change from one Base to another. So let's look at Base 10 to see what we can find out about the rules that apply to any Base.

  • Base 10 has 10 digits. These digits include 0-9. We can say that Base 10 uses digits that are 0 to 10-1. If we call the Base X, the legal digits in that Base are 0 to X-1. REMEMBER x=the base.

Look at this number in Base 10: 1200

  • Columns work from right to left. As a column hits 10, the next column is used leaving a 0 and moving to the next column. We can say that the first column represents X0 or "1's column", the next column represents X1 or 10's column, the next column represent X2 , or 100's column, and so forth.

  • Therefore 1200 actually equals ---- X0 * 0 + X1 *0 + X2 * 2 + X3 * 1 OR we could say it like this X3 * 1 + X2 * 2 + X1 * 0 + X0 * OR 0*1 + 0*10 + 2*100 + 1*1000=1200

  • NOTE: X0 = 1

Assembly language is the language of 1's and 0's which is easy for computers to understand BECAUSE computers are electronic devices that understand ON and OFF (ie 1 and 0). If you turn OFF a light switch you are representing a "0". If you turn ON a light switch you are representing a "1". Computer systems have circuitry (gates) that are either Open or Closed (ON or OFF). These instructions are sent to them by the Assembly program (machine language).

  • The system is capable of processing multiples of 8 bits (8 "1s" and/or "0s" = 1 Byte) of information (and groups of these) depending on memory size. The more memory your computer has, the more instructions it can handle at once, therefore it is faster. To simplify how binary is represented, programmers use 8-bit binary numbers that can be written using Hexadecimal (Hex) or Base 16.

Let's apply the Base rules we have learned to Base 16

  • The legal digits are 0 to 16-1. Obviously, we can't use a 10, 11, 12, 13, 14, 15 in a single column, so programmers use 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F to represent the legal digits in Hex where A = 10, B = 11, C = 12, D=13, F=14.

EXAMPLE conversion:

CB97356 = 6 *X0 + 5* X2 + 3* X3 + 7* X 4 + 9* X 5 + 11*X 6 + 12*X 7 OR (6 * 1) +(5 * 16) + (3* 4096) + (7*65,536) + (11*104,8576) + (12 * 16777216) = Yes it is a huge number

What is a Hex number 800000. See if you can calculate the actual value of this Hex number by converting it to Base 10.

  • Hex numbers are 6 digits long and are used to represent colors in HTML, the language used to create Web pages. What color is 800000? Use this resource. https://htmlcolorcodes.com/ We will use Hex colors when we write some HTML in our last module.

EXERCISES:

On your slides for Module_08, convert these Hex numbers to Base 10. Show your work! Then check your work here --> https://www.rapidtables.com/convert/number/hex-to-decimal.html

  • FF5733

  • AD6656

  • 1A1615

  • 16151A

  • 151A16

Create a document for Module 8 that explains the following vocabulary

  • bit

  • byte

  • registers

  • nibbles in binary

  • assembly language

  • compiler

  • assembler