CS 334

Advanced Introduction to Computer Organization and Architecture


Module 1 : Component 2.4 

Information Representation



These notes are intended to guide your studies and to make it easier to read and understand the text. In no way are they to be a substitute for reading and studying the text itself.  

We know how to count in binary, how to add, how to use a fixed number of digits and how to manipulate numbers in two's complement notation including the roles of the C and V bits. Furthermore we know all about logical and arithmetic operators. 


Hexadecimal or radix 16

Hexadecimal digits are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F where A is 10, B is 11, C is 12, D is 13, E is 14, and F is 15. We are interested in base 16 since it is easier to write and speak numbers in hex than in binary and trivial to convert from one of these bases to the other. Let the computer count the number of zeros in 100000100001000 we would prefer to not waste our time (besides I would almost always get it wrong anyway). 


Counting in hex

The numbers 0 through 15 are represented by the corresponding digits in base 16.  

1016 represents 16  

1116 represents 17  

1916 represents 25  

1A16 represents 26  

1F16 represents 31  

2016 represents 32  

2116 represents 33  

10016 represents 16 2 or 256  

100016 represents 16 3 cubed or 4096  

3A516 represents 3*256 + 10*16 + 5 or 933.  


BFA19 represents  

  B * 164 +   F * 163 +   A * 162 + 1 * 16 + 9    or  

11 * 164 + 15 * 163 + 10 * 162 + 1 * 16 + 9 

On homework you may use calculator to confirm or correct your answers on problems like this. On a test go ahead and add it up manually but show the above form also, if the form is correct but the addition wrong it will be a minus one at most. 


Conversions from hex to binary and back

Since the radix of hex representations is 16 or 24 it is easy to convert hex to/from binary. First build a conversion table by counting from 0 to 15 in both hex and binary. This should not take long since we know how to count in binary and in hex..  

 

Binary Number

Hex Digit

0000 

0

0001 

1

0010 

2

0011 

3

0100 

4

0101 

5

0110 

6

0111 

7

1000 

8

1001 

9

1010 

A

1011 

B

1100 

C

1101 

D

1110 

E

1111 

F

 

If we can remember these 16 patterns we can do the conversion. In fact you need not remember. If you can count to 15 in hex and in binary and you can build this table yourself whenever you need it. 


Conversion from hex to binary

Convert each hex digit into its corresponding binary value. What could be simpler? With a little practice you will be able to do it without thinking.  
  

Example: 

AF57 in hex becomes 1010 1111 0101 0111 in binary. 

Look it up in the table to see if I am correct. In fact you need not look it up. A is ten or 8 + 2 hence the 1010. F is fifteen and fifteen is 8 + 4 +2 +1 hence the 1111. Five is 4 + 1 but you must think of it as 0*8 + 1*4 + 0*2 + 1 or 0101. Likewise seven is 0*8 + 1*4 + 1*2 + 1 or 0111. Actually I recommend that you build the translation table and just look them up as this prevents errors. 
  


Conversion from binary to hex

This is tougher. First starting on the right end of your binary number separate the binary digits into groups of 4. Notice that the leftmost group may have less than 4 digits. Translate the groups individually into the corresponding hex digits.  
  

Example 1 

 1100010101110100110100   in binary is frightening. 

First group it into groups of 4 digits from the right end.  

11  0001  0101  1101  0011  0100 

Now it is not quite so scary. The right most group is 0100 it will be converted into hex digit 4. The next group from the right is 0011 which converts into 3. The next group is 1101 which is D. 0101 becomes 5 and 0001 becomes 1. That leaves 11 in binary which hopefully we recognize as 3 but if not add two zeros on the left to get 0011 and look it up in the table.  

11 0001  0101 1101 0011 0100 in binary becomes 

3 1 5 D 3 4 in hex. 

Normally written without the spaces 315D3416 
  
  

Example 2 

101 0101 0110 1011 in binary becomes 556B16 

1110 1111 0101 1001 in binary becomes EF5916


Octal numbers radix 8

The digits are of course 0,1,2,3,4,5,6 and 7. Eight is written as 10 and sixty four is written as 100.  
  

Counting in Octal  

08 is 0.  

78 is 7.  

108 is 8.  

118 is 9.  

128 is 10.  

178 is 15.  

208 is 16.  

218 is 17.  

778 is 7 * 8 + 7 or 63.  

1008 is 64 or 8 squared.  

1018 is 65. 


What number is 567218 

Hopefully you can do this by now, not necessarily in your head but on paper.  

5* 84 + 6 * 83 + 7 * 82 + 2 * 8 + 1  



You are now ready to attack section 3.4 in the text.  

The base conversion material and examples should be easy for you after studying the material above.

Study the material on characters, pages 113-115 carefully. You should be able to read the ASCII table on page 112. No need to memorize it, as I will provide a copy of it for you as needed on tests.  


 

Homework 2: Part 4

 

Do problems 27, 28 and 31-38 on page 141-142 in the text. Turn in 32a along with the problems from parts 1, 2, 3 and 5 of this component.

That was part four of five take a break you deserve it.  

Wow, wasn't that break refreshing.  Now we can move on to floating point numbers in section 3.5.   However you will be glad to know that section 3.6 is read only rather than a study section.


  Component 2.5

 

 

 

 


Schedule 

 


All images and text are Copyright 1999-2010 by Dr. Larry Wilson

This material is subject to copyright and unauthorized use or copying is prohibited.