CSCI2327 Assignment 2
CSCI2327 Assignment 2
Question 1
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.
(1×2power4)+(1×2 power3)+(0×2power2)+(1×2power1)+(1×2power0)
=16+8+0+2+1=27
Question 2:
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:
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
Hexadecimal: 4244500016
Question 8 :