Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. [6 marks] Conversion - Show your work (as illustrated in lectures). Convert e

ID: 3750992 • Letter: 1

Question

1. [6 marks] Conversion - Show your work (as illustrated in lectures). Convert each of the decimal numbers below into an 8-bit unsigned binary number, then convert the binary number into a hexadecimal number. a. I. 15710 Il 24810 b. Convert each of the decimal numbers below into an 8-bit signed (two's complement) binary number, then convert the binary number into a hexadecimal number. I 12310 -7410 Interpret each of the binary numbers below first as a signed decimal number, then as an unsigned. c. 111010012 Il 100101102

Explanation / Answer

Here are all the solutions as asked. Please rate the answer if you find it helpful.

a.

(i) Convering 15710 to 8-bit binary

To convert any decimal number (base 10) to binary, we repeatedly divide the number with 2. The remainders of all the division taken from reverse order will give us the binary number.

Below is the division process, where Q = quotient at each step and R = remainder at each step.

157/2 = 78(Q) + 1(R)

78/2 = 39(Q) + 0(R)

39/2 = 19(Q) + 1(R)

19/2 = 9(Q) + 1(R)

9/2 = 4(Q) + 1(R)

4/2 = 2(Q) + 0(R)

2/2 = 1(Q) + 0(R)

1/2 = 0(Q) + 1(R)

Taking all the remainders in reverse order will give 10011101 is the binary representation of 157.

Converting 10011101 to hexadecimal

For converting a binary number directly to hexadecimal, we identify 4 bits together starting from the least significant bit towards right. If there are no enough bits, we pad it with 0's towards the left till we get 4 bits.

So, here 10011101 can be broken into 1001 1101. Now convert each of the 4-bits into decimal form and then interpolate with the number in Hex notation. Lets do the conversion here.

1001 = 9 in decimal = 9 in hexadecimal in as well.

Similary 1101 = 13 in decimal = D in hexadecimal.

So, the number 12310 = 100111012 = 9D in hexadecimal.

(ii) By applying similar logic, we can convert 24810 to binary as follows.

248/2 = 124(Q) + 0(R)

124/2 = 62(Q) + 0(R)

62/2 = 31(Q) + 0(R)

31/2 = 15(Q) + 1(R)

15/2 = 7(Q) + 1(R)

7/2 = 3(Q) + 1(R)

3/2 = 1(Q) + 1(R)

1/2 = 0(Q) + 1(R)

So, number in binary is 11111000

Converting this to hexadecimal. We apply the same logic as in (i)

1111 1000

1111 = 15 in decimal = F in hexadecimal

1000 = 8 in decimal = 8 in hexadecimal.

Therefore, the number is F8 in hexadecimal.

b. Convert decimal to 8-bit signed (2's compliment)

(i)

12310

Since this is a positive number, converting it in signed binary straightforward (placing 0 in the signbit apart from the value)

= 1111011 is value in binary.

We'll have 0 as sign bit since it is a positive number = 0 1111011

Binary to hexadecimal conversion can be done as in (a).

So, 111 0111 can be padded as 0111 1011 to make it easy for hexadecimal conversion.

= 7B in hexadecimal.

Since the sign bit is 0, the number still remains postive, i.e., 7B

(ii)

-7410

First, lets convert to binary

-7410 = 1 10010102

Now to convert into 2's compliment, we invert all the bits and then add 1 to least significant bit

= 1 1001010 => 1 0110101 (also called 1's compliment)

Now we'll add 1 to it

1 0 1 1 0 1 0 1

+ 1

-------------------------

1 0 1 1 0 1 1 0 ( in 2's compliment)

-----------------------

Converting 10110110 to hexadecimal

We take 4 bits each as we did a(i) and (ii) and b(i) and then convert each of those 4 bits into hexadecimal.

So, 10110110 can be broken into 1011 0110

1011 = 11 in Decimal = B in Hexadecimal.

0110 = 6 in Decimal = 6 in Hexadecimal as well.

Therefore 101101102 = B616

c. Interpret binary number as signed and unsigned decimal number

In case of signed number, we dedicate the Highest Significant Bit (Left most) for the sign. Hence whatever is in the left most bit, we should not caculate the value of it. Instead we should denote the number as negative if that bit 1 and positive if the sign bit 0.

In case of unsigned, it is simple decimal conversion.

(i) 111010012 converting to unsigned decimal

1 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 1 x 20 = 128+ 64 + 32 + 8 + 1 = 233

Now, in case of converting to signed decimal, we consider the Left most bit as sign bit and won't take it in value calculation.

So, the above number in signed binary form would be

1 1101001

= - (   1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 1 x 20 ) = -105

(ii) We'll follow the same logic for coverting 100101102 as well.

Converting it to unsigned binary

= 1 x 27 + 0 x 26 + 0 x 25 + 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20

= 128 + 0 + 0 + 16 + 0 + 4 + 2 + 0 = 150

And for converting it into signed binary, we'll take the left most as sign bit

1  0010110

= - (  0 x 26 + 0 x 25 + 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 )

= -22