Assignment 1 - I did ok! PDF

Title Assignment 1 - I did ok!
Course Computer and Logic Essentials
Institution Swinburne University of Technology
Pages 7
File Size 265.8 KB
File Type PDF
Total Downloads 71
Total Views 171

Summary

I did ok!...


Description

Computer Logic Essentials: Assignment 1 Name: Dinh Gia Bao HOANG Student ID: 102072661 Point taken by surname: Point 1

Question 1: a) Convert the following decimal to hexadecimal value. Starting point 1: 3597 Divide the base and take remainder 3597/16 = 224, remainder: 13 224/16 = 14, remainder: 0 14/16, remainder: 14 0x Baseposition#

E 162

0 161

D 160

Answer: 3597 = 0xE0D

b) Convert the following negative value to its 8–bit two’s complement Starting point 1: -123 Divide the base and take remainder of the positive number. 123/ 2 = 61, remainder: 1 61/2 = 30, remainder: 1 30/2 = 15, remainder: 0 15/2 = 7, remainder: 1 7/2 = 3, remainder: 1 3/2 = 1, remainder: 1 1/2, remainder: 1 0b Baseposition#

0 (positive) Sign

1 26

1 25

1 24

1 23

0 22

1 21

1 20

Positive number in binary: 0b 0111 1011 Flip all the bits to indicate a negative number (one’s complement): 0b 1000 0100 Add 1 (Two’s complement): 0b 1000 0101 Answer: -123 = 0b 1000 0101

c) Convert the following decimal value to IEEE 754 single precision floating point. Please write your final answer with spaces between the sign, exponent, and mantissa. Starting point 1: 53.125 Positive number, Sign = 0

Covert the integer of 53 to binary: 53/2 = 26, remainder: 1, 26/2 = 13, remainder: 0 13/2 = 6, remainder: 1 6/2= 3, remainder: 0 3/2 = 1, remainder: 1 1/2, remainder: 1 0b Baseposition#

1 25

1 24

Finding the Mantissa: Integer = 0b110101, fraction: 0.125 0.125 x 2 = 0.25 0.25 x 2 = 0.5 0.5 x 2 = 1.0 0.0x2 = 0.0 0.0x2 = 0.0 0.0x2 = 0.0 The pattern continues with ending 0. Stop at 24 bits => M = 110101.001000000000000000 Then, M = 1.10101001000000000000000 x 25 The mantissa: M = 10101001000000000000000

Noting that we have 25 at M, finding the exponent Exp = 5 + 127 = 132 Convert 132 into binary: 132/2 = 66, remainder: 0 66/2 = 33, remainder: 0 33/2 = 16, remainder: 1 16/2 = 8, remainder: 0 8/2 =4, remainder: 0 4/2 = 2, remainder: 0

0 23

1 22

0 21

1 20

2/2 = 1, remainder: 0 1/2, remainder: 1 0b Baseposition#

1 27

0 26

0 25

0 24

0 23

1 22

0 21

0 20

 The exponent: 132 = 0b10000100 Final number in IEEE 754 format: sign exponent mantissa Answer: 0 10000100 10101001000000000000000

Question 2: Starting point 1: 0b 1100 1010 0011 1001 a) Convert the 16-bit binary number given in your starting point, to its hexadecimal value. Using the grouping method for every 4 bits, to represent a digit of hexadecimal number. 0b 1100 1010 0011 1001 0b1100 = 1x22 + 1x23 = 4 + 8 = 12 = 0xC 0b1010 = 1x21 + 1x23 = 2 + 8 = 10 = 0xA 0b0011 = 1x20 + 1x21 = 1 + 2 = 3 = 0x3 0b1001 = 1x20 + 1x23 = 1 + 8 = 0x9 Answer: 0b 1100 1010 0011 1001 = 0xCA39

b) Convert the 16-bit binary number given in your starting point, to two 8-bit unsigned integers in decimal. 0b 1100 1010 0011 1001 to two 8-bit unsigned integers in decimal: First number: 0b 1100 1010 = 0x20 + 1x21 + 0x22 + 1x23 + 0x24 + 0x25 + 1x26 + 1x27 = 2 + 8 + 64 + 128 = 202 Second number: 0b 0011 1001 = 1x20 + 0x2 + 0x2 + 1x23 + 1x24 + 1x25 + 0x2 +0x2 = 1 + 8 + 16 + 32 = 57 First number = 202, second number = 57

c) Covert the 16-bit binary number given in your starting point, to two 8-bit signed integers (two’s complement) in decimal. 0b 1100 1010 0011 1001 First 8-bit signed integer (two’s complement): 0b 1100 1010 To one’s complement (minus 1): 0b 1100 1001.

Flip all the bits: 0b 0011 0110 To decimal: 0b 0011 0110 = 0 + 2 + 4 + 16 + 32 = 54. The Two’s complement binary has the first bit of 1 which means negative, the first 8-bit signed integers in decimal: -54

Second 8-bit signed integer (two’s complement): 0b 0011 1001 Because the first sign bit is 0 which means positive, simply covert it to decimal 0b 0011 1001 = 1 + 1x23 + 1x24 + 1x25 = 1 + 8+ 16+ 32 = 57 The second 8-bit signed integer in decimal: 57

Answer: first number: -54, second number: 57.

d) Convert the 16-bit binary number given in your starting point, to one half-precision (16 bit) floating point value as a decimal value One half-precision (16 bit) floating point has a format: sign (1 bit), exponent (5 bit), fraction (10 bit) Starting point: 1 10010 1000111001 Sign = 1 To calculate the bias for an arbitrarily sized floating point number, applying the formula 2k−1 − 1 where k is the number of bits in the exponent. The exponent has 5 bits. Exponent Bias = 25-1 -1 = 16 -1 = 15 Exponent = 0b10010 – Exponent Bias = 21 + 24 – 15 = 18- 15 = 3 10 bits for the mantissa, assume 1 at the MSB M = 1.1000111001 = 20 + 2-1 + 2-5 + 2-6 + 2-7 + 2-10 = 1.5555664 Final equation: number = (-1)s x M x 2Exp = (-1)1 x 1.5555664 x 23 = -12.445

Answer: number = -12.445

Question 3: a) 0b1100 1100 multiply by 0b110 (*)

Answer: 0b 0100 1100 1000

b) 0b1100 1010 added to 0b1010 0001 (*)

Answer: 0b 0001 0110 1011 c) 0b 0100 1010 subtracted from to 0b 1110 0101

Answer: 0b 1001 1011

Question 4: The following Unicode characters (in UTF-8 encoding). Express the message contained in the Unicode code points. Explain briefly how you detected the characters (note you are expected to demonstrate this in binary/octal). 50 61 6E 64 65 6D 69 63 21

Firstly, it is recognisable that there is no character greater than U+007F which means these characters are completely represented in UTF-8. In UTF-8, represents numbers with one byte, using 7 bits prefaced by a 0. The last two digits are also the digits represented in hexadecimal. From that, the hexadecimal number will be represented in binary through group methods. Then fill in the binary with the format: 0xxxxxxx. Finally, it can be looked up from ASCII converter table to find the characters.

UTF-8

Hexadecimal

First digit to binary

Second digit to binary

U+0050 U+0061 U+006E U+0064 U+0065 U+006D U+0069 U+0063 U+0021

50 61 6E 64 65 6D 69 63 21

0x5 = 0b101 0x6 = 0b110 0x6 = 0b110 0x6 = 0b110 0x6 = 0b110 0x6 = 0b110 0x6 = 0b110 0x6 = 0b110 0x2 = 0b010

0x0 = 0b0000 0x1 = 0b0001 0xE = 0b1110 0x4 = 0b0100 0x5 = 0b0101 0xD = 0b1101 0x9 = 0b1001 0x3 = 0b0011 0x1 = 0b0001

The message: Pandemic!

Combining and putting 0 as preface 0b01010000 0b01100001 0b01101110 0b01100100 0b01100101 0b01101101 0b01101001 0b01100011 0b00100001

Look up from ASCII table P a n d e m i c !...


Similar Free PDFs