CS Homework
CS Homework
237 – 213 = 24
1110 1101 = 237
0101 1110
80+14=94
0 1110 0101
128 + 64 + 32 + 4 + 1 = 229
F = 15, 0D5
255
6. Represent the decimal number -57 in 8-bit two's complement binary form.
-128 64 32 16 8 4 2 1
1100 0111
0010 1101
8. Convert the 8-bit two's complement binary number 11100101 to its decimal
equivalent.
-128 + 64 + 32 + 4 + 1
-27
9. Given the 8-bit two's complement binary number 11001101, determine if it's
positive or negative, then convert it to decimal and hexadecimal.
Negative
-128 + 64 + 8 + 4 + 1 = -51
F = 15, CD
Extend the algorithm to convert a denary integer number into its binary representation by
dividing the number successively by 2 and noting the remainders, so that it works also for
fractional numbers. You must specify the entire algorithm, step by step. (Hints: a. work
separately on the integral and the fractional parts; b. for the fractional part consider doing
the "opposite" of what you do for the integral part.)
Start with the fractional part of the decimal number you want to convert.
Repeat the following steps for a fixed number of binary places (e.g., 16) or until the
fractional part becomes zero (whichever comes first):
a. Multiply the fractional part by 2.
b. Note the integer part of the result (either 0 or 1).
c. Add the integer part to the end of the binary representation.
d. Update the fractional part to be the decimal part of the result (i.e., remove the integer
part).
Continue this process until you have the desired number of binary places or the fractional
part becomes zero.
0001 0111.1010
1010 0011.0100
128 + 32 + 2 + 1 + 0.25
163.25
F = 15, D6
8 + 4 + 1 + 0.25 + 0.125
13.375
14. Convert the decimal number -23.5 to its binary equivalent using two's complement
for the integer part.