CS101 Solution
Tuesday, November 06, 2012 Edit ThisInput:
Microphone
Digital pen
Touch pad
Question # 2
Output:
Speakers
Multimedia Projector
Processing Device:
CPU
Some of them are Both Input and Out put depending on their Usage:
Modem (Modem in called an I/O device, but i prefer to use it as Input because you are receiving data from Modem)
CD/DVD disc (Depending on Usage whether you are reading data or writing data)
Network Adapter (It is also an I/O Device whether you are receiving data, Or sending data)
USB flash drive (Depending on Usage whether you are reading data or writing data)
Question # 2
.................................................. ........
Method One: Short Division by Two with Remainder
This method is much easier to understand when visualized on paper. It relies only on division by two.
1
Set up the problem. For this example, let's convert the decimal number 15610 to binary.
- Write the decimal number as the dividend inside an upside-down "long division" symbol.
- Write the base of the destination system (in our case, "2" for binary) as the divisor outside the curve of the division symbol.
- 2
Write the integer answer (quotient) under the long division symbol, and write the remainder (0 or 1) to the right of the dividend.
- Basically, if the dividend is even, the binary remainder will be 0; if the dividend is odd, the binary remainder will be 1.
- 3
Continue downwards, dividing each new quotient by two and writing the remainders to the right of each dividend. Stop when the quotient is 0.
- 4
Starting with the bottom remainder, read the sequence of remainders upwards to the top. For this example, you should have 10011100. This is the binary equivalent of the decimal number 156. Or, written with base subscripts: 15610 = 100111002
- This method can be modified to convert from decimal to any base. The divisor is 2 because the desired destination is base 2. If the desired destination is a different base, replace the 2 in the method with the desired base. For example, if the desired destination is base 9, replace the 2 with 9. The final result will then be in the desired base.
Method Two: Descending Powers of Two and Subtraction
- 1
List the powers of two in a "base 2 table" from right to left. Start at 20, evaluating it as "1". Increment the exponent by one for each power. The list, to ten elements, would look like this: 512, 256, 128, 64, 32, 16, 8, 4, 2, 1
- 2
Figure out the greatest power that will fit into the number you want to convert to binary. For this example, let's convert the decimal number 15610 to binary. What is the greatest power of two that will fit into 156? Since 128 fits, write a 1 for the leftmost binary digit, and subtract 128 from your decimal number, 156. You now have 28.
- 3
Move to the next lower power of two. Can 64 fit into 28? No, so write a 0 for the next binary digit to the right.
- 4
Can 32 fit into 28? No, so write a 0.
- 5
Can 16 fit into 28? Yes, so write a 1, and subtract 16 from 28. You now have 12.
- 6
Can 8 fit into 12? Yes, so write a 1, and subtract 8 from 12. You now have 4.
- 7
Can 4 (power of two) fit into 4 (working decimal)? Yes, so write a 1, and subtract 4 from 4. You have 0.
- 8
Can 2 fit into 0? No, so write a 0.
- 9
Can 1 fit into 0? No, so write a 0.
- 10
Put together the binary answer. Since there are no more powers of two in the list, you are done. You should have 10011100. This is the binary equivalent of the decimal number 156. Or, written with base subscripts: 15610 = 100111002.
- Repetition of this method will result in memorization of the powers of two, which will allow you to skip Step 1.
410 = 110011010
101101 = 45
To convert Decimal to Binary or Binary to Decimal use opposite method for each