1 / 11

Hexadecimal & Decimal Conversions

Hexadecimal & Decimal Conversions. Hexadecimal to Decimal & Back Again Mr. Akuna 2009. Introduction to Hexadecimal Numbers.

trinav
Download Presentation

Hexadecimal & Decimal Conversions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hexadecimal & Decimal Conversions Hexadecimal to Decimal & Back Again Mr. Akuna 2009

  2. Introduction to Hexadecimal Numbers • Hexadecimal numbers (sometimes called hex for short, when used in the context of computers) are taken from the words hex, meaning six, and decimal, meaning ten, so combining the two you get 16 (6 + 10). • Hexadecimal numbers are numbers just like decimal numbers but are in base 16 instead of base 10. The base tells you how many digits can be used. In base 10 (decimal) there are 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 In base 16 (hexadecimal) there are 16: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

  3. Introduction to Hexadecimal Numbers • Now that we know what digits are involved let’s compare them to their decimal equivalents To repeat in base 16 (hexadecimal) there are 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Hexadecimal Decimal Equivalent • Notice from the table that after we reach 9 the next number in decimal requires two digits while for hexadecimal you only need 1 character. This becomes important when you want to show large numbers. We will get back to this, but first let’s take another look at decimal numbers.

  4. A Closer Look at Decimal To better understand hexadecimal let’s take a closer look at decimal numbers. For example, the number 1274. You understand the number, but let’s break down the digit in each position. Next take the value for each position. Add 1000*1 + 100*2 + 10*7 + 1*4 = 1274notice 10000 is not added in since its position is implied as a leading 0, and all leading zeros are ignored. Probably all this is obvious to you since you work with decimal numbers all the time.

  5. Hexadecimal to Decimal Conversion Let’s apply what we just did in decimal to hexadecimal. For example, the hexadecimal number 1AF9. Just like we did in decimal let’s break down the digit in each position. Next take the value for each position. Add 4096*1 + 256*10 + 16*15 + 1*9 = 6905(decimal)notice an extra step was used to convert the characters A and F to their decimal equivalents but the process was the same as before just like the decimal number 1274.

  6. Hexadecimal Notation • Okay so we can take a hexadecimal number 1AF9 and convert it to its decimal equivalent, 6905. How about the number 1023. Just saying the number 1023 doesn’t make it clear whether this is a hexadecimal number 1023 or a decimal 1023 and we know these two numbers are not the same. • To avoid such problems we notate hexadecimal numbers in several possible ways as shown in the following: • 0x1023 the 0x being the notation for hexadecimal • 1023h the h being the notation for hexadecimal • Hex 1023 • Hexadecimal numbers are used to give color information in HTML code, such as #FF80CC, where the # is the notation for hexadecimal. Also important is the hexadecimal number is NOT interpreted as a single number, but rather three sets of 2 hexadecimal digits, each representing one of three colors, RGB.

  7. RGB Provided in Hexadecimal • RGB, Red, Green and Blue, is used in HTML to provide a specific color designation, to give the hexadecimal color it would be #RRGGBB. • Each color is represented by two hexadecimal characters, • # being the notation for hexadecimal • RR being red with a value range of 00 to FF (0 to 255 decimal) • GG being green with a value range of 00 to FF (0 to 255 decimal) • BB being blue with a value range of 00 to FF (0 to 255 decimal) • To convert this type of hexadecimal number you first split the hexadecimal number into 3 sets of 2. For example #FF80CC: 16*15+1*15=255 16*8+1*0=128 16*12+1*12=204 #FF80CC = RGB(255, 128, 204)

  8. Check for Understanding • What is the value of 0x2D45 ? • What is the value of A10Eh ? • What is the value of #FF0080 ? 11589 41230 RGB (255, 0, 128)

  9. Decimal to Hexadecimal Conversion

  10. Check for Understanding • What is decimal 15309 in hexadecimal? • What is decimal 9156 in hexadecimal? • What is decimal 255 in hexadecimal? Hexadecimal Decimal 3BCD 15309 23C4 9156 FF 255

  11. Final Check for Understanding • Click on this link to bring up the Hexadecimal-Decimal Worksheet. • Print & complete the worksheet • Turn in this worksheet with your other assignments.

More Related