Task 1.3: Convert the following hexadecimal numbers into base 7 numbers:
format: [hexadecimal number] '\t' [base-7 number] '\n'
sample: ACH 334
BFH
34H
123H
8AH
Note that all the answers should be written in a text file called Answer2_1.txt and uploaded through the gradebot.
Task 2: Number Representation
Task 2.1: Give the value of +34, -34 , -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 +34, -34 , -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'
Task 2.3: Suppose that IEEE-754 32-bit floating-point representation pattern is 1 1000 0001 010 1000 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 010 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 and uploaded through the gradebot.
This part of homework will be graded by hand.
Task 3: Programming
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 B+A, B+A*2,…,B+A*N .
Every element in the sequence is regarded as binary number. Your program should output how many bits are true in the sequence.
0<=A,B,N<=1e6
Input
A B N
Output
[output the answer in a decimal number]
Sample Input
5 8 2
Sample Output
5
Notes
Note that this program must be written in C! Please submit your source file called task3.c and Makefile in a folder called task3. Executable file should be called task3 and also placed in the folder called task3.
Your program has to be able to compile using gcc -Wpedantic -Wall -Wextra -Werror -std=c89 .