1 / 21

Week 2 Introduction to the Hexadecimal Number System

DH2T 34 – HNC Computer Architecture 1. Week 2 Introduction to the Hexadecimal Number System. © C Nyssen/Aberdeen College 2004 All images © C Nyssen /Aberdeen College unless otherwise stated

othello
Download Presentation

Week 2 Introduction to the Hexadecimal Number System

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. DH2T 34 – HNC Computer Architecture 1 Week 2 Introduction to the Hexadecimal Number System © C Nyssen/Aberdeen College 2004 All images © C Nyssen /Aberdeen College unless otherwise stated Arc de Triomphe, compass, chess, caterpillar, binary printer all © romtech, with non-distribution licence Convict fish © Mark Pelissier, with permission Confused man © clipart.com, with non distribution licence Lady with Mark 1© Manchester University, with permission Prepared 7/9/04

  2. The number 16 is not a “natural” counting base for 10-fingered humans. However it appears a lot in human society – because of the unique properties of the number 16. It is an exact square - 42, or 24.

  3. The first four odd numbers added – 1+3+5+7 equals 16. A compass rose is divided into 16 points. Chessboards have 16 black and 16 white pieces. They are divided into four quadrants of 16 squares each.

  4. Bookbinders use a standard format of sixteenmo – the paper is divided into sixteen leaves. Caterpillars usually have 16 legs! (But only 6 when they become butterflies). Pre-decimal Imperial weights and measures used 16oz to a pound.

  5. We saw last week that computers can only store and manipulate data in a binary base – base 2. The earliest computer programs were written in binary by highly trained mathematicians. They were, however, highly prone to errors….

  6. … because the human eye becomes very confused when dealing with large groups of similar looking objects!

  7. A method had to be found to “convert” large binary numbers to something that humans find easier to read and manipulate. As base 2 does not convert to base 10 very easily, we use base 16 – hexadecimal – instead.

  8. You can buy special base-converting calculators to convert values between binary, decimal, hexadecimal and octal (a base of 8). Or a useful website is -http://www.calculator.org/CalcHelpCD/basen.html

  9. Each hexadecimal column uses a power of 16. But we only have 10 digits – numbered 0 to 9 – so to make up 16 symbols, we use the letters A – F as well. 0 1 2 3 4 5 6 7 8 9 A B C D E F

  10. Some examples of computers displaying information in a hexadecimal format…. h2.arch, h3.arch { align = "center"; background-color: ffcccc; } h1.java { font-size: 110%; font-family: trebuchet; background-color: 99ff66; }

  11. Converting binary to hex is easy – exploiting the relationship between the numbers 4 and 16. Begin by dividing the binary number into “nibbles” – groups of 4 – working from right to left.

  12. Each nibble can only hold a value of between 0 and 15. Replace each nibble with the equivalent hexadecimal digit…. …and 16 binary digits have been replaced with 4 hexadecimal ones!

  13. It works the other way round, too…. …expand each hexadecimal digit to four binary ones…. …and your 8-digit hexadecimal number has become a 32-bit binary one!

  14. Sometimes you will have to convert directly from decimal to hex…. …we use the long division process that we looked at last week with the binary conversion.

  15. To convert a decimal number – 7896532 - to hexadecimal … …start by dividing by 16 … …and continue until you run out of numbers. (When dividing, just do the whole numbers, ignore the remainders for the moment…)

  16. Now we turn our attention to the remainders – multiply them all by 16 to get the red column on the right….. …read from the BOTTOM UP to get 787DD4h … …or0111 1000 0111 1101 1101 0100in binary!

  17. To convert from hex to decimal, we use the “hexadecimal columns” method to multiply and add. 5 x 4096 = 20480 F or 15 x 256 = 3840 7 x 16 = 112 B or 11 x 1 = 11 20480 + 3840 + 112 + 11 = 24443

  18. You can, of course, convert from hex – binary – decimal if you prefer…. DAF3h 1101 1010 1111 00112 5605110 ….and back again from decimal – binary – hex…. 5707210 1101 1110 1111 00002 DEFOh …because they all mean exactly the same value, it’s just expressed in different ways. Note that sometimes a lowercase ‘h’ is used to mean “hexidecimal base”.

  19. It is important to remember that computers do not actually store things in hexadecimal. Everything is stored in binary! 1101 1111 0000 0100 Computers just display things in hexadecimal to make life easier for the human audience.

  20. One for you to try….. FACE16 in binary? 0101 0000 1101 0000 1111 11112 in hex?

  21. Summary • Although computers store and manipulate values in binary, they usually display them in hexadecimal format. • Each group of four bits corresponds to one hexadecimal digit. • Hexadecimal digits run from 0 -9 then A – F. • The value of each hexadecimal digit rises by a power of 16 as the columns move to the left. • Hexadecimal values are usually followed by a lowercase “h”, or a small 16.

More Related