Question: 6. Algorithm to Convert From Decimal To Another Base 1. Let n be the decimal number. 2. be the number,intl empty, that we are converting
6. Algorithm to Convert From Decimal To Another Base 1. Let n be the decimal number. 2. be the number,intl empty, that we are converting to. We'll be composing it right Let t m 3. 4. to left. Let b be the base of the number we are converting to. Repeat until n becomes 0 Divide n by b, letting the result be d and the remainder be r. Write the remainder, r, as the leftmost digit of b. Let d be the new value of n. Let's use the algorithm to convert 45 into binary. Let n 45. Let b 2. Repeat 45 divided by b is 45/2 22 remainder 1. So da22 and r-1. So 1 and the new n is 22. So d-11 and r-1. So m 01 and the new n is 11 So da5 and r-1. So m 101 and the newn is 5 So de2 and r-1. So ma 1101 and the new n is 2. So de1 and ro. So me 01101 and the new nis1. So deo and r-1. So m-101101 and the new n is o. So 450 101101 22 divided by b ia 22/2 11 remainder 11 divided by b is 11/2 5 remainder 1 5 divided by b is 5/22 remainder 1 2 divided by b is 2/21 remainder . 1 divided by b is 1/20 remainder 1. You are to implement and Algorithm to convert A decimal Number ( base 10) to a Binary Number base 2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
