Homework 2

Computer Architecture I ShanghaiTech University
HW1 HW2 HW3

Task 1: Number Systems Conversion

Task 1.1: Convert the following decimal numbers into binary and hexadecimal numbers:

format: [decimal number] '\t' [binary number] '\t' [hexadecimal number] '\n'
sample: 108 1101100B 6CH

82
91
13
55

Task 1.2: Convert the following hexadecimal numbers into binary and decimal numbers:

format: [hexadecimal number] '\t' [binary number] '\t' [decimal number] '\n'
sample: ABH 10101011B 171

F3H
3C5H
191H
47H

Task 1.3: Convert the following hexadecimal numbers into base 7 numbers:

format: [hexadecimal number] '\t' [base-7 number] '\n'
sample: ACH 334

6AH
4CH
56H
30H
Note that all the answers should be written in a text file called Answer2_1.txt, replace "*" with your answer and all letters should be captitalized, then uploaded through the gradebot.

Task 2: Number Representation

Task 2.1: Give the value of +25, -25 , -1, 0, +1, -128, and +127 in 8-bit 2's complement signed representation.

format: [decimal number] '\t' [8-bit 2's complement signed representation] '\n'

Task 2.2: Give the value of +25, -25 , -1, 0, +1, -127 and +127 in 8-bit 1's complement representation.

format: [decimal number] '\t' [8-bit 1's complement signed representation] '\n'

Tasks 2.3 and 2.4 are not part of this homework anymore - floating point number representation will be covered later in the course.

Task 2.3: Suppose that IEEE-754 32-bit floating-point representation pattern is 1 0111 1100 010 0000 0000 0000 0000 0000.

What is the decimals when this representation is in the normalized form?

Task 2.4: Suppose that IEEE-754 32-bit floating-point representation pattern is 1 0000 0000 001 1000 0000 0000 0000 0000.

What is the decimals when this representation is in the normalized form and de-normalized form ?

Notes

Note that all answers should be written in a text file called Answer2_2.txt, replace "*" with your answer and all letters should be captitalized, then uploaded through the gradebot.
This part of homework will be graded by hand.

Task 3: Programming (subject to small changes)

In this task you need to write a C program about bit operation.
3 non-negative integers A, B and N are given, from these numbers you will get a sequence A+B, A+B*2,…,A+B*N .
Every element in the sequence is regarded as binary number. Your program should output how many bits are false in the sequence, assuming 64bit unsigned integers.
0<=A,B,N<=1e6

Input

A B N

Output

[output the answer in a decimal number]

Sample Input

8 5 2

Sample Output

123

Notes