Chapter03-0DataRepresentation
Chapter03-0DataRepresentation
2015
COMPUTER ARCHITECTURE
CSE Fall 2014
Faculty of Computer Science and Engineering
Department of Computer Engineering
BK
TP.HCM
Vo Tan Phuong
http://www.cse.hcmut.edu.vn/~vtphuong
dce
2015
Chapter 3
Data Representation
– Characters
Most Least
– Floating-point numbers
Significant Bit Significant Bit
– Images, sound, etc.
7 6 5 4 3 2 1 0
1 0 0 1 1 1 0 1
• Bit Numbering 27 26 25 24 23 22 21 20
7 6 5 4 3 2 1 0
1 0 0 1 1 1 0 1
27 26 25 24 23 22 21 20
Some common
powers of 2
37 = (100101)2
Example:
Solution:
E B 1 6 A 7 9 4
1110 1011 0001 0110 1010 0111 1001 0100
• Examples:
stop when
quotient is zero
Double Word 64
carry 1 1 1 1
0 0 1 1 0 1 1 0 (54)
+ 0 0 0 1 1 1 0 1 (29)
0 1 0 1 0 0 1 1 (83)
bit position: 7 6 5 4 3 2 1 0
• Example:
carry: 1 1 1
1C37286A
+ A + B = 10 + 11 = 21
9395E84B Since 21 ≥ 16
Sum = 21 – 16 = 5
AFCD10B5 Carry = 1
• 0 = positive 1 1 1 1 0 1 1 0
Negative
0 0 0 0 1 0 1 0 Positive
– Add 1
• Examples:
2's complement of 6A3D = 95C2 + 1 = 95C3
borrow: 1 1 1 carry: 1 1 1 1
01001101 01001101
– 00111010 + 11000110 (2's complement)
00010011 00010011 (same result)
Borrow: 1 1 1 Carry: 1 1 1 1 1
B14FC675 B14FC675
- +
839EA247 7C615DB9 (2's complement)
Practice: What is the range of signed values that may be stored in 20 bits?
0 0 0 0 1 1 1 1 15 0 0 0 0 1 1 1 1 15
+ +
0 0 0 0 1 0 0 0 8 1 1 1 1 1 0 0 0 248 (-8)
0 0 0 1 0 1 1 1 23 0 0 0 0 0 1 1 1 7
1 1 1 1
0 1 0 0 1 1 1 1 79 1 1 0 1 1 0 1 0 218 (-38)
+ +
0 1 0 0 0 0 0 0 64 1 0 0 1 1 1 0 1 157 (-99)
1 0 0 0 1 1 1 1 143 0 1 1 1 0 1 1 1 119
(-113)
Carry = 0 Overflow = 1 Carry = 1 Overflow = 1
Borrow = 1 Carry = 1
Finite Set of Unsigned Integers
Subtraction Addition
Negative Positive
Finite Set of Signed Integers
Overflow Overflow
min = -2 n-1
0 max = 2n-1–1
0 1 2 3 4 5 6 7 8 9 A B C D E F
2 space ! " # $ % & ' ( ) * + , - . /
3 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 @ A B C D E F G H I J K L M N O
5 P Q R S T U V W X Y Z [ \ ] ^ _
6 ` a b c d e f g h i j k l m n o
7 p q r s t u v w x y z { | } ~ DEL
Examples:
ASCII code for space character = 20 (hex) = 32 (decimal)
ASCII code for 'L' = 4C (hex) = 76 (decimal)
ASCII code for 'a' = 61 (hex) = 97 (decimal)
s E (exponent) F (fraction)
1 bit 8 bits 23 bits
– The base (2, not 10) is hardwired in the design of the FPALU
– More bits in the fraction (F) or the exponent (E) is a trade-off
between precision (accuracy of the number) and range (size of
the number)