Download presentation

Presentation is loading. Please wait.

Published byMonica Amason Modified over 2 years ago

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 - 4 2, or 2 4.

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. Pre-decimal Imperial weights and measures used 16oz to a pound. Caterpillars usually have 16 legs! (But only 6 when they become butterflies).

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. 655364096256161 16 4 16 3 16 2 16 1 16 0 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. 1 0 0 11 1 1 00 0 1 11 0

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! 1 0 0 11 1 1 00 0 1 11 0 914 or E310 or A

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! E7F4C01D 11100111111101001010000000011011

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 … …or 0111 1000 0111 1101 1101 0100 in binary!

17
To convert from hex to decimal, we use the “hexadecimal columns” method to multiply and add. 16 3 16 2 16 1 16 0 4096’s256’s16’s1’s 5F7B 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…. ….and back again from decimal – binary – hex…. DAF3h1101 1010 1111 0011 2 56051 10 …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”. 1101 1110 1111 0000 2 DEFOh57072 10

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

20
One for you to try….. FACE 16 in binary? 1111101011001110 0101 0000 1101 0000 1111 1111 2 in hex? 50D0FF

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.

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google