![]() The remainders are still pushed onto the stack until the value being converted becomes 0. The “Divide by 2” idea is simply replaced with a more general “Divide by base.” A new function called convert_to_base, shown below, takes a decimal number and any base between 2 and 16 as parameters. ![]() The function convert_to_binary can be modified to accept not only a decimal value but also a base for the intended conversion.
0 Comments
Leave a Reply. |