Solutions_HW2 - Remo Pillat 06/25/2006 CDA 3103 Summer 2006...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Remo Pillat 06/25/2006 CDA 3103 – Summer 2006 Assignment 2 - Solutions Question 1 (20 points) Convert -511 into a 32-bit two’s complement binary number. Answer: Convert the positive number 511 first to binary. Knowing that 9 512 2 = , we know that 90 511 512 1 2 2 10 0000 0000 00 0000 0001 0111111111 =− = = A different method to find the binary representation would be by using the division-by-2 method. 511 2 255 1 ( ) 255 2 127 1 127 2 63 1 63 2 31 1 31 2 15 1 15 2 7 1 723 1 321 1 12 0 1 ( ) R LSB R R R R R R R R MSB ÷= Since we search for a 32-bit precision, the binary number is: 0000 0000 0000 0000 0000 000111111111 The two’s complement of this number can be found by inverting all bits (one’s complement) and adding 1 to that: + = 1111 1111 1111 1111 1111 1110 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001 1111 1111 1111 1111 1111 1110 0000 0001 This results equals -511.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Question 2 (20 points) Given the bit pattern 1000 0000 1110 1010 1100 0000 0000 0000 What does it represent assuming that it is a. an unsigned integer b. a two’s complement integer c. a single precision floating point number Answer: a. an unsigned integer The unsigned integer can be found by assigning weights to the bits =+++++++ = 31 23 22 21 19 17 15 14 1000 0000 1110 1010 1100 0000 0000 0000 22222222 2 162 868 224 You can make the same calculation in hexadecimal (this is probably slightly faster): () = = +∗ = 2 16 7543 1000 0000 1110 1010 1100 0000 0000 0000 80 0 0 0 81 6 1 41 01 21 6 2 162 868 224 EA C b. a two’s complement integer The two’s complement number uses the same method of weights, but the sign of the weight of the MSB is negative. Hence: = +++++++ =− 31 23 22 21 19 17 15 14 1000 0000 1110 1010 1100 0000 0000 0000 2 132 099 072
Background image of page 2
3 c. a single precision floating point number The 32 bits of the floating point number are divided into the following parts Sign Exponent Mantissa 18 23 0 31 In our case: 1000 0000 1110 1010 1100 0000 0000 0000 Sign Bit= 1 (Negative Number) Exponent= 0000 0001 (=1) Mantissa= 1.1101 0101 1 (=1.833984375) Remember that the real exponent is the calculated exponent – 127.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Solutions_HW2 - Remo Pillat 06/25/2006 CDA 3103 Summer 2006...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online