Docsity

High Performance Computing Lecture 2: Data Representation in Computing, Slides of Computer Science

Partial preview of the text

Download High Performance Computing Lecture 2: Data Representation in Computing and more Slides Computer Science in PDF only on Docsity!

High Performance Computing

Lecture 2

2 How is Data Represented?

 Character data: ASCII code

 Integer data

4

Representing Signed Integer Data

 Sign-magnitude representation

xn 1 xn 2 x 2 x 1 xo

  represents the value

 

 2 0

1 n i i

x i

xn

least significant bit (lsb) Example: In 8 bits 13 is represented as 00001101

  • 13 is represented as 10001101 Sign bit

5 Alternative: 2s Complement Representation x (^) n 1 xn 2 x 0 ...   The n bit quantity represents the signed integer value     

2 0 1 1 2 2 n i i i n x n x least significant bit Example: In 8 bits 13 is represented as 00001101

  • 13 is represented as 11110011
    • 128 + 64 + 32 + 16 + 2 + 1

7 Which Representation is Better?

 Considerations

 Speed of arithmetic (addition, multiplication)  Speed of comparison  Range of values that can be represented

 The 2s complement representation is widely

used

8 How is Data Represented?

 Character data: ASCII code

 Signed Integer data: 2s complement

 Real data

10 Real Data: Floating Point Representation

IEEE Floating Point Standard (IEEE 754)

32 bit value with 3 components ( s, e , f )

1. s (1 bit sign) 2. e (8 bit exponent) 3. f (23 bit fraction)

represents the value

127 ( 1 ) 1. 2     s e f

11

Consider the decimal value 0.

 Equal to 0.1 in binary

 s: 0, e: 126, f: 000…

 In 32 bits,

1

  1. 0 2   127 ( 1 ) 1. 2     s e f Example: IEEE Single Float

13 More on IEEE Floating Point

 Why is the exponent represented in this way?

(excess-127 representation for signed

integers)

 Normalized representation

 Special forms

 Denormalized values (exp = 0; f = non-zero)  Zero (exp = 0; f = 0)  Infinity (exp = 255; f = 0)  NaN (exp = 255; f = non-zero)

14 How is Data Represented?

 Character data: ASCII code

 Signed Integer data: 2s complement

 Real data: IEEE floating point