Titlebar
Home FAQ and Resources 2.1.1 Fundamentals

2.1.2 Hardware

2.1.3 Software 2.1.4 Data 2.1.5 Databases 2.1.6 Comms & networks 2.1.7 Programming


 

2.1.4 Data representation


a) Units of storage

b) Converting to binary

c) Converting to binary

d) Binary addition

e) Hexadecimal conversion

f) Binary - Hex conversion

g) The need for Hex

h) Binary codes

i) Character sets

j) Representing characters

k) Images as pixels

l) Metadata

m) Colour depth and resolution

n) Storing sound

o) Size and quality of sound files

p) Instructions as bit patterns

q) Instructions and data



2.1.4 e) Converting between positive denary whole numbers and hex

Introduction
We know that a digit's worth depends on what position it is in relative to the other digits in the number.

  • Base 10 positions are worth 107, 106, 105, 104, 103, 102, 101, 100
  • Base 2 positions are worth 27, 26, 25, 24 23, 22, 21, 20
  • Base 16 positions are worth 167, 166, 165, 164, 163, 162, 161, 160

How does the hexadecimal system work? The first thing to note is that there are 16 'numbers' in this system: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. It may well seem a little odd using letters to represent numbers: 10=A, 11=B, 12=C, 13=D, 14=E, 15=F. With a little practice, you will see what an excellent system this is.

Just to remind you, to show what system is being used when you write down a number, it is common to use a subscript. So for example: 3410 means (3 x 10) + (4 x 1) whereas 3416 means (3 x 16) + (4 x 1)

As you know, when we write down numbers in our daily life, we omit the subscript because we assume that every one is using base 10. Sometimes, especially in computer circles, it is a dangerous assumption to make! If there is any doubt, then add a subscript! When doing exam questions, always use a subscript, just to show how clever you are!

Let's convert a few hex numbers into denary. For the first few you do, you should write down the worth of each position. Then write the number you are converting underneath it. Finally, do the conversion.

Example 1: convert 3C 16 into decimal.

Worth of each position
256 (162)
16 (161)
1 (160)
Number to convert
 
3
C


3C16 is the same as (3 x 16) + (12 x 1) = 6010

Example 2: convert 2516 into decimal.

Worth of each position
256 (162)
16 (161)
1 (160)
Number to convert
 
2
5

2516 is the same as (2 x 16) + (5 x 1) = 3710

Example 3: convert 816 into decimal.

Worth of each position
256 (162)
16 (161)
1 (160)
Number to convert
 
8

816 is the same as (8 x 1) = 810

Example 4: convert 3AF16 into decimal.

Worth of each position
256
16
1
Number to convert
3
A
F

3AF16 is the same as (3 x 256) + (10 x 16) + (15 x 1) = 94310

converting from decimal to hex
Going from hex to denary is relatively easy after you've done a few of them. You have to think a little bit harder going the other way, from denary to hex. But there is a great trick you can use - if you can use binary.

Binary and hex are actually very closely related, much more so than first appears. Each hex digit is just a group of four bits!! As long as we can do binary to denary conversion off the top of our heads, there is a method for converting denary to hex (and also back again) very quickly. See if you can follow this example. We are going to convert 12510 into a hex number.

g

h

i

j

You should always check the hex answer you got. 7D16 = (7 x 16) + (13 x 1) = 12510 so our answer is correct.
(Of course, you could always check your answer using a calculator! In Windows, Go to WINDOWS - ACCESSORIES - CALCULATOR - VIEW - SCIENTIFIC).

k

l

You should always check the hex answer you got. 4B16 = (4 x 16) + (11x 1) = 7510 so our answer is correct. This may seem a little long-winded to start with, but this method is very mechanical and always works. Once you've done a few, you'll be an expert. Besides, it's good practice for binary conversion!

Q1. Convert these numbers into their denary form: a) 3616      b) 316     c) FA16     d) 15 16
Q2. Convert these decimal numbers into hex: a) 103 10      b) 1410      c) 5810     d) 7 10
Q3. Why are nibbles important when using hex?         
  

 


 

 
 

 

V1.0 Copyright theteacher.info Ltd 2011