The user will type in a string of binary digits: 10101100. The program will read this as a string of ASCII characters, since that is the only way the computer knows how to read input from the keyboard (function 0AH, int 21h). Therefore, the input will be stored in the computer as an array of bytes. Each byte will represent one of the digits: 30h = '0', 31h = '1'. | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
Your program should then convert each ASCII byte into the number that it represents: 31h to 1, 30h to 0. | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
Then it is time to calculate the number that is represented by the string.
Whenever converting from a string to a number, use the Multiplication Algorithm
Here is the Multiplication Algorithm for this string:
After all the digits have been processed, the Total holds the number that is equivalent to the original string. Note: Do not be confused by the base that is used to represent the total, it is irrelevant. It is only important to understand that by doing the arithmetic, a number has been generated from a string. If humans are doing the conversion, then numbers will be represented in based 10. If the computer is doing the conversion, then numbers are stored in base 2. |