1
198:211
Computer Architecture
l
Topics:
l
Data representation 2.1 and 2.2 of the book
l
Floating point
2.4 of the book
Lecture 8,9
(W5)
Fall 2012

2
Computer Architecture
l
What do computers do?

3
Number System
l
Comprises of
l
Set of numbers or elements
l
Operations on them (+
- / *)
l
Rules that define properties of operations (identity,
inverse
…
)
l
Need to assign value to numbers
l
Let us take decimal system
l
1
’
s place, 10
’
s place, 100
’
s place etc
l
Base 10
l
Value=
l
Humans use decimal
∑
×
i
i
10

4
Binary numbers
l
Base 2; each digit is 0 or 1
l
Each bit in place
i
has value 2
i
l
Binary representation is used in computers
l
Easy to represent by switches (on/off)
l
Manipulation by Digital logic in hardware
l
But hard for humans to read
l
(13)
10
= (1101)
2

5
Hexadecimal representation
l
Binary hard to read for humans
l
Especially 16 bits, 32 bits, 64 bits
l
1010101001010101
l
Base 16 representation or hex representation
l
Symbols ={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
l
Value =
l
First
10 (0 through 9) symbols are same as
decimal numbers
l
A=10,B=11,C=12, D=13, E=14, F=15
∑
×
i
i
16

6

Same for Hex
7
l
Example: Convert
10 in decimal to binary
l
The code
for binary works for any base with modifications
l
For
hex, replace by N%16
and N=N/16 replace
reminders > 9 by A, B, C, D, E and F
l
Example: Convert 240 to HEX

8
Binary to decimal
l
Convert 110110 to decimal
l
Value = i*2
i
l
Value = 2
5
2
4
2
2
2
1
l
= 32+ 16 + 4 + 2
l
= 54
l
l

9
Converting Hex to binary
l
Each digit in Hex can be represented by 4 bit
binary (base 16) or nibble
l
Convert 2A8C to binary
l
0010 1010 0100 1100

10
Convert Binary to hex
l
Group binary bits into groups of four
l
Replace each nibble by a hex digit
l
Example 1011011110011100
l
1011
0111
1001
1100
l
B
7
9
C
or 0x
B
7
9
C
l
In C, numeric constants starting with 0x are
interpreted as being in hexadecimal

11
Examples
l
0x8F7A93 to binary
l
1011011110011100 to hex
l
0xC4E5 to decimal
