3.8. Converting Decimal Numbers To Binary Numbers - Problem Solving With Algorithms and Data Structures
3.8. Converting Decimal Numbers To Binary Numbers - Problem Solving With Algorithms and Data Structures
Converting Decimal Numbers to Binary Numbers — Problem Solving with Algorithms and Data Structures
Chapters
Integer values are common data items. They are used in computer programs and computation all the
time. We learn about them in math class and of course represent them using the decimal number
system, or base 10. The decimal number \(233_{10}\) and its corresponding binary equivalent \
(11101001_{2}\) are interpreted respectively as
and
But how can we easily convert integer values into binary numbers? The answer is an algorithm called
“Divide by 2” that uses a stack to keep track of the digits for the binary result.
The Divide by 2
http://interactivepython.org/runestone/static/pythonds/BasicDS/ConvertingDecimalNumberstoBinaryNumbers.html 1/1