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

CS Homework

The document provides examples of converting between binary, decimal, octal, and hexadecimal number systems. It then provides an algorithm to extend the conversion method to fractional numbers by dividing the fractional part by 2 repeatedly and noting the remainders to generate the binary representation.

Uploaded by

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

CS Homework

The document provides examples of converting between binary, decimal, octal, and hexadecimal number systems. It then provides an algorithm to extend the conversion method to fractional numbers by dividing the fractional part by 2 repeatedly and noting the remainders to generate the binary representation.

Uploaded by

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

1.

IConvert the binary number 11010101 to decimal and hexadecimal


128 64 32 16 8 4 2 1
128 + 64 + 16 + 4 + 1
213
2. Convert the decimal number 237 to binary and hexadecimal.

237 – 213 = 24
1110 1101 = 237

3. Convert the hexadecimal number 5E to binary and decimal.

0101 1110
80+14=94

4. Convert the octal number 345 to binary, decimal, and hexadecimal.

2048 1024 512 256 128 64 32 16 8 4 1


7 = 111 (octal)

0 1110 0101
128 + 64 + 32 + 4 + 1 = 229
F = 15, 0D5

5. Convert the binary number 10101101 to octal.

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

7. Represent the decimal number 45 in 8-bit two's complement binary form.

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 decimal (denary) number you want to convert.


Repeat the following steps until the number becomes zero:
a. Divide the number by 2.
b. Note the remainder (either 0 or 1).
c. Add the remainder to the beginning of the binary representation.
Continue this process until the decimal number becomes zero.

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.

10. Convert the binary number 101.1101 to decimal.

128 64 32 16 8 4 2 1 0.5 0.25. 0.125 0.06125


4 + 1 + 0.5 + 0.25 + 0.06125
5.8225
11. Convert the decimal number 23.625 to binary.

0001 0111.1010

12. Convert the hexadecimal number A3.4 to binary and decimal.

1010 0011.0100
128 + 32 + 2 + 1 + 0.25
163.25

13. Convert the binary number 1101.011 to hexadecimal and decimal.

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.

-128 64 32 16 8 4 2 1 0.5 0.25 0.125 0.06125


1110 1001.1000

You might also like