COS10003 Assignment 01
COS10003 Assignment 01
CLASS: COS10003
Topic
Assignment 1
INSTRUCTOR:
Dr. Van Ho
STUDENT NAMES:
Vu Thanh Phong
ID:
104486950
HO CHI MINH CITY – June 2023
Starting point 2:
1a)
1698/256 = 6, remainder = 162
162/16 = 10, remainder = 2
2/1 = 2, remainder = 0
1686 = 0x6A2
1b)
42/2 = 21, remainder = 0
21/2 = 10, remainder = 1
10/2 = 5, remainder = 0
5/2 = 2, remainder = 1
2/2 = 1, remainder = 0
1/2 = 0.5, remainder = 1
42 in binary = 0b00101010
Flip all the bits: 0b11010101
Add 1-bit = 0b11010110
8-bits two’s complement of -42 is 0b11010110
1c)
236.5 is a positive number, so sign = 0
236/2 = 118, remainder = 0
118/2 = 59, remainder = 0
59/2 = 29, remainder = 1
29/2 = 14, remainder = 1
14/2 = 7, remainder = 0
7/2 = 3, remainder = 1
3/2 = 1, remainder = 1
1/2= 0.5, remainder = 1
236 in binary = 0b 1110 1100
Fraction = 0.5
0.5 x 2 = 1
The positive number before normalisation = 1110 1100.10000000000000000000000
Normalise the number = 1.110110010000000000000000000000x 27
M = 11011001000000000000000
Exp = 7 + 127 = 134
134/2 = 67, remainder = 0
67/2 = 33, remainder = 1
33/2 = 16, remainder = 1
16/2 = 8, remainder = 0
8/2 = 4, remainder = 0
4/2 = 2, remainder = 0
2/2 = 1, remainder = 0
1/2 = 0.5, remainder = 1
134 in binary = 0b1000 0110
236.5 in IEEE 754 single precision = 0 10000110 11011001000000000000000
2b)
0010 1111 = 1x 2^5 + 1 x 2^3 + 1 x 2^2 + 1 x 2^1 + 1 x 2^0 = 47
1001 1010 = 1 x 2^7 + 1 x 2^4 + 1 x 2^3 + 1 x 2^1 = 154
2c)
The MSB of 0010 1111 is 0 which means it is a positive number. Therefore, the number does not
change:
0010 1111 = = 1x 2^5 + 1 x 2^3 + 1 x 2^2 + 1 x 2^1 + 1 x 2^0 = 47
The MSB of 1001 1010 is 1 which means it is a negative number. Therefore, the number needs
to go through the process of two’s complement
1001 1010 – 1 = 1001 1001
Flip all the bits = 0110 0110
0110 0110 = 1x 2^6 + 1 x 2^5 + 1 x 2^2 + 1 x 2^1 = 102
1001 1010 in two’s complement representation is -102
3) df 81 e2 91 a1 34 f0 9d 8d a7
df = 1101 1111
81 = 1000 0001
e2 = 1110 0010
91 = 1001 0001
a1 = 1010 0001
34 = 0011 0100
f0 = 1111 0000
9d = 1001 1101
8d = 1000 1101
a7 = 1010 0111
11011111 10000001 11100010 10010001 10100001 00110100 11110000 10011101 10001101
10100111
To convert the given code to UTF-8 encoding, the hexadecimal codes need to be converted to 8-
bits binary. Then match those codes to the correct group and the prefaced bits (in bold) are
removed.
1st code point 11011111 10000001 = 111 1100 0001 => U+07C1
2nd code point 11100010 10010001 10100001 = 0010 0100 0110 0001 => U+2461
3rd code point 00110100 = 011 0100 => U+0034
4th code point 11110000 10011101 10001101 10100111 = 0 0001 1101 0011 0110 0111 =>
U+1D367
U+07C1: ߁
U+2461: ②
U+0034: 4
U+1D367: 𝍧