Computer Architecture Data Representation Mark S. Staveley Mark.Staveley@mun.ca.

Post on 29-Dec-2015

221 views 0 download

Tags:

Transcript of Computer Architecture Data Representation Mark S. Staveley Mark.Staveley@mun.ca.

Computer Architecture

Data Representation

Mark S. Staveley

Mark.Staveley@mun.ca

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3127

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

3217/2 = 1608 R 1 (Least Significant Bit)1608/2 = 804 R 0 804/2 = 402 R 0 402/2 = 201 R 0 201/2 = 100 R 1 100/2 = 50 R 0 50/2 = 25 R 0 25/2 = 12 R 1 12/2 = 6 R 0 6/2 = 3 R 0 3/2 = 1 R 1 1/2 = 0 R 1 (Most Significant Bit)

321710 = 1100100100012

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

3217/8 = 402 R 1 (Least Significant Bit)

402/8 = 50 R 2

50/8 = 6 R 2

6/8 = 0 R 6 (Most Significant Bit)

321710 = 62218

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

3217/16 = 201 R 1 (Least Significant Bit)

201/16 = 12 R 6

2/16 = 0 R C (1210 Most Significant Bit)

321710 = C6116

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221 C91

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221 C91

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221

110011010001

6271

B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

B3816

B16 – 10112

316 – 00112

816 – 10002

1011001110002

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221

110011010001

6271

101100111000 B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

1011001110002

Split on 3-bits (base 8)

1012 – 58

1002 – 48

1112 – 78

0002 – 08

54708

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221

110011010001

6271

2872 101100111000 5470 B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

1011001110002 =

0 x 20 + 0 X 21 + 0 X 22 + 1 X 23 + 1 x 24 + 1 x 25 + 0 x 26 + 0 x 27 + 1 x 28 + 1 x 29 + 0 x 210 + 1 x 211

= 287210

Binary Coded Decimal Representation

Decimal Binary Octal Hexadecimal

3217 110010010001 6221 C91

3281 110011010001 6321 CD1

3257 110010111001 6271 CB9

2872 101100111000 5470 B38

Complete the following table. Each row represents a specific unsigned integer value in the different radix forms listed in the table. For example, 1210 can be written as 11002,

14 8 or C16.

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21

-17

+14

-32

+31

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

+21 (convert to Sign & Magnitude)

Sign = + = 1

21 convert to 5-bit representation = 10101

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

+21 (convert to One’s Complement)

Result = same as normal because it is positive = 010101

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

+21 (convert to Two’s Complement)

Result = same as normal because it is positive = 010101

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

+21 (Convert to Excess 31)

Positive and negative representations of a number are obtained by adding a bias to the two’s complement representation, ignoring any carry out from the most

significant digit.21 in Two’s Complement = 010101

Bias = 31 = 011111

010101 + 011111 = 110100

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -32 (convert to Sign & Magnitude)

Sign = - = 1

32 convert to 5-bit representation = Error

Why? Greatest number represented with 5 bits is 31 (11111) 32 is out of range.

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -32 (One’s Complement)

Sign = - = 1

32 convert to 5-bit representation = Error

Why? Greatest number represented with 5 bits is 31 (11111) 32 is out of range.

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -32 (convert to Two’s Complement)

Minimum 2's complement value = -2n-1

Maximum 2's complement value = 2n-1 – 1

n = 6 = Max = +31, Min = -32

-32 converted = 100000

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -32 (Convert to Excess 31)

Largest Negative Number = 000000 = - 31

Largest Positive Number = 111111 = + 32

Out of Range = N/A

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -17 (convert to Sign & Magnitude)

Sign = - = 1

17 convert to 5-bit representation = 10001

Result = 110001

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -17 (One’s Complement)

Sign = - = 1

17 convert to 5-bit representation = 10001

Complement each bit = 01110

Result = 101110

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110 -17 (convert to Two’s Complement)

Add One to One’s Complement

101110 + 1 = 01111

Result = 101111

Complete the table below using 6-bit representation for sign and magnitude, ones’ complement, two’s complement, and excess 31. Each row in the table is to show a specific numerical value in the different data representations listed in the table. Note that for each numeric value listed below, it may not be possible to represent that value in all the data

representations – in these cases just specify ‘N/A’.

Decimal Sign & Magnitude

One’s Complement

Two’s Complement

Excess 31

+21 010101 010101 010101 110100

-17 110001 101110 101111 001110

+14 001110 001110 001110 101101

-32 N/A N/A 100000 N/A

+31 011111 011111 011111 111110

-17 (Convert to Excess 31)

Positive and negative representations of a number are obtained by adding a bias to the two’s complement representation, ignoring any carry out from the most

significant digit.17 in Two’s Complement = 101111

Bias = 31 = 011111

101111 + 011111 = 001110

Fill in the following steps to find the representation for –17.5 in the IEEE single-precision floating-point standard.

IEEE-754 Floating Point Standard° Developed in 1985. It can be supported in hardware, or a

mixture of hardware and software.

° There are also single extended, and double extended formats (80 bits wide, 15-bit exponent, and 64-bit fraction).

Excess-127

Excess-1023 Hidden bit

Hidden bit

Fill in the following steps to find the representation for –17.5 in the IEEE single-precision floating-point standard.

a) Convert –17.5 to base 2:

b) Express the value from (a) in binary scientific notation:

c) Convert the exponent from (b) to excess 127:

d) IEEE single point precision representation:

Fill in the following steps to find the representation for –17.5 in the IEEE single-precision floating-point standard.

a) Convert –17.5 to base 2: –10001.12

Fill in the following steps to find the representation for –17.5 in the IEEE single-precision floating-point standard.

b) Express the value from (a) in binary scientific notation:

–1.000112 * 24

Fill in the following steps to find the representation for –17.5 in the IEEE single-precision floating-point standard.

c) Convert the exponent from (b) to excess 127:

12710 + 410 = 11111112 + 1002 = 100000112

Fill in the following steps to find the representation for –17.5 in the IEEE single-precision floating-point standard.

d) IEEE single point precision representation:

Sine Bit = Negative = 1

Exponent = 12710+410 = 13110 = 100000112

Fraction = 1.000112 (leading 1 of fraction is hidden)

= 00011000000000000000000

1 10000011 00011000000000000000000

Convert the following floating point numbers represented in IEEE single precision floating point representation to both binary and decimal representations in scientific notation, where feasible.

1 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

101000012 = 16110;

161 – 127 = 34;

–1.110012 * 234

Convert the following floating point numbers represented in IEEE single precision floating point representation to both binary and decimal representations in scientific notation, where feasible.

0 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

011110102 = 12210;

122 – 127 = –5;

1.02 * 2–5 = 1.010 * 2

–5 = 0.03125 = 3.125 * 10-2

Convert the following floating point numbers represented in IEEE single precision floating point representation to both binary and decimal representations in scientific notation, where feasible.

0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

100000012 = 12910;

129 – 127 = 2;

1.10102 * 22 = 110.102 = 6.5 = 6.5 * 100

Convert the following floating point numbers represented in IEEE single precision floating point representation to both binary and decimal representations in scientific notation, where feasible.

1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

111000002 = 22410;

224 – 127 = 97;

–1.011001112 * 297

Do the following using two’s complement arithmetic and indicate the carry (C) and overflow (V) values.

(e.g., “C = 1” if there is a carry, “C = 0” otherwise).

 

a) 0 1 0 1 1 1 b) 0 1 1 0 0 0 c) 1 0 1 1 0 1

+ 0 1 0 0 1 1 - 0 1 1 1 0 0 - 1 0 1 0 0 1

C = C = C =

V = V = V =

 

d) 1 1 0 0 1 1 e) 1 0 1 1 0 0 f) 0 1 1 1 1 1

- 0 0 0 0 0 1 + 1 0 0 1 1 0 + 1 0 1 0 1 0

C = C = C =

V = V = V =

Do the following using two’s complement arithmetic and indicate the carry (C) and overflow (V) values.

(e.g., “C = 1” if there is a carry, “C = 0” otherwise).

 

a) 0 1 0 1 1 1 b) 0 1 1 0 0 0 c) 1 0 1 1 0 1

+ 0 1 0 0 1 1 - 0 1 1 1 0 0 - 1 0 1 0 0 1

1 0 1 0 1 0 = 0 1 1 0 0 0 0 0 0 1 0 0

+ 1 0 0 1 0 0

1 1 1 1 0 0

C = 0 (no carry) C = 0 C = 1

V = 1 (sum out of range) V = 0 V = 0

Note: When the CPU adds two binary integers, if their sum is out of range when interpreted in the two’s complement representation, then V is set to 1. Otherwise V is cleared to 0

Do the following using two’s complement arithmetic and indicate the carry (C) and overflow (V) values.

(e.g., “C = 1” if there is a carry, “C = 0” otherwise).

 

 

d) 1 1 0 0 1 1 e) 1 0 1 1 0 0 f) 0 1 1 1 1 1

- 0 0 0 0 0 1 + 1 0 0 1 1 0 + 1 0 1 0 1 0

1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1

C = 1 C = 1 C = 1

V = 0 V = 1 V = 0