0% found this document useful (0 votes)
8 views

CSCI2327 Assignment 2

The document contains a series of mathematical problems and solutions related to number base conversions, binary arithmetic, and representations in various formats such as signed magnitude and two's complement. It includes detailed steps for converting numbers between decimal, binary, octal, hexadecimal, and floating-point formats, as well as Hamming code generation. Additionally, it addresses overflow issues in binary addition and provides examples of signed and unsigned comparisons.

Uploaded by

adam05sabri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

CSCI2327 Assignment 2

The document contains a series of mathematical problems and solutions related to number base conversions, binary arithmetic, and representations in various formats such as signed magnitude and two's complement. It includes detailed steps for converting numbers between decimal, binary, octal, hexadecimal, and floating-point formats, as well as Hamming code generation. Additionally, it addresses overflow issues in binary addition and provides examples of signed and unsigned comparisons.

Uploaded by

adam05sabri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CSCI2327 Assignment 2

Question 1

a) Convert 534 base 10 to base 3


534÷3=178 remainder 0
178÷3=59 remainder 1
59÷3=19 remainder 2
19÷3=6 remainder 1
6÷3=2 remainder 0
2÷3=0 remainder 2
Therefore, 534 base 10 = 201210 base 3

b) Convert 253 base 10 to base 5

253÷5=50 remainder 3
50÷5=10 remainder 0
10÷5=2 remainder 0
2÷5=0 remainder 2
Therefore, 253 base 10=2003 base 5.

c) Convert 1738 base 9 to decimal

17389=(1×9power3) + (7×9power2) +(3×9power1)+(8×9power0) = 1


1×729=729
7×81=567
3×9=27
8×1=8
729+567+27+8=1331
Therefore 1738{9}=1331{10}
d) Convert 1265 base 7 to decimal
base7=(1×7power3)+(2×7power2)+(6×7)+(5×7power 0)= 488 base 10

e) Convert 29.59375 base 10 to binary


Convert the integer
29÷2=14remainder 1
14÷2= 7remainder 0
7÷2=3 remainder 1
3÷2=1 remainder 1
1÷2=0 remainder 1
29=11101 base 2
Convert the fractional part
0.59375×2=1.1875 → 111
0.1875×2=0.375 → 000
0.375×2=0.75→ 000
0.75×2=1.50 → 111
0.5×2=1 → 111 So, 0.59375 base 10=0.10011 base 2
Therefore, 29.5937510=11101.10011 base 2
f) Convert 11011.1011 to decimal

Convert the integer part 11011 to decimal:

(1×2power4)+(1×2 power3)+(0×2power2)+(1×2power1)+(1×2power0)

=16+8+0+2+1=27

Convert the fractional part 0.1011 to decimal:

(1×2power−1) + (0×2 power −2)+(1×2 power −3)+(1×2 power −4)=0.6875

Combine the integer and fractional parts:

Therefore, 11011.1011 base 2=27.6875 base 10

Question 2:

a)11111100 is larger as an unsigned binary number.


b) 01111001 is larger in signed two's complement representation.
c) 11111100 is smaller in signed-magnitude representation.

Question 3:

Binary:

Hex binary
B 1011
A 1010
D 1101
D 1101
0 0000
0 0000
D 1101
6 0110
0 0000
E 1110
5 0101
F 1111
0 0000
0 0000
0 0000
Step 2: Binary to Octal

000 101 110 101 101 110 100 000 000 000 000 000 110 000 011 100 101 111 100 000 000 000

=0 5 6 5 7 4 0 0 0 0 3 0 7 5 7 4 0 0 0:

Step 3: Binary to base -4

10 11 10 10 11 01 11 01 00 00 00 00 00 11 00 00 01 11 01 11 11 00 00 00 00 this translates to

23223131000003013330000

Question 4:

a) 48

For the number 48, the signed magnitude representation uses the binary equivalent of 48,
which is 00110000. The most significant bit (MSB) is 0, indicating that the number is
positive. In one’s complement, since 48 is positive, the binary representation remains the
same: 00110000. Similarly, in two’s complement, the representation does not change because
the number is positive, resulting in 00110000 as well. Lastly, in excess-127 representation, we
calculate 48+12748 + 12748+127, yielding 175. The binary representation of 175 is
10101111, making it the excess-127 representation for the number 48. Thus, across all
formats, 48 is straightforwardly represented as a positive integer.

B) 35

For the negative number -35, the signed magnitude representation first involves finding the
binary of 35, which is 00100011. To indicate negativity, the MSB is set to 1, resulting in
10100011. In one’s complement, we start with the positive representation of 35 and invert the
bits to get 11011100. For two’s complement, we take the one’s complement result and add 1,
giving us 11011101. This representation is essential for computer arithmetic, as it allows for
straightforward addition of positive and negative numbers. Lastly, in excess-127
representation, we calculate −35+127-35 + 127−35+127, which equals 92. The binary of 92 is
01011100, serving as the excess-127 representation for -35. Thus, -35 is represented in
various forms that facilitate its use in binary arithmetic operations.

Question 5:

In the calculation of -11 - 119 using 8-bit two's complement, we first converted -11 to binary
as 11110101 and 119 to 01110111. Adding these two results in 10101000, which is equivalent
to -88 in decimal after inverting and adding one. There was no overflow since the operands
had different signs, and the carry flag was 0, making this result valid. In the second
calculation,

120 + 11, we represented 120 as 01111000 and 11 as 00001011. Adding these gives
10000011, which represents -125 in decimal, indicating overflow since both operands were
positive and the result was negative. The carry flag here was 1 due to the carry out of the
MSB, rendering this result invalid. Thus, while the first calculation was valid, the second one
encountered an overflow issue.

Question 6:

To store the floating-point number 17.33203125 using the IEEE-754 single precision format,
we first convert the number to binary, resulting in 10001.01010101. Normalizing this, we
shift the binary point to get 1.000101010101×2 Power 4 .The sign bit is 0, indicating a
positive number. The exponent, calculated as 4+127=131, is represented in binary as
10000011. The significand is derived from the bits following the leading 1 in the normalized
form, yielding 000101010101 and padded with zeros to reach 23 bits:
00010101010100000000000. Combining these components, we get the final 32-bit binary
representation as 0 10000011 00010101010100000000000, which converts to the
hexadecimal value 41315000. This complete representation captures the necessary
information for the floating-point format.

Question 7:

The hexadecimal number 4244500016 can be converted to binary by converting each hex
digit to its 4-bit binary equivalent:

 4 → 0100
 2 → 0010
 4 → 0100
 4 → 0100
 5 → 0101
 0 → 0000
 0 → 0000
 1 → 0001
 6 → 0110

Putting these together, we have:

Hexadecimal: 4244500016

Question 8 :

Hamming Code for 1101 1010: 10101100


Hamming Code for ASCII Character 'Y' (01011001): 10001101

You might also like