Question: To convert a number to binary: 1 . Stop if the number is zero 2 . Use the remainder operator ( % ) to divide
To convert a number to binary:
Stop if the number is zero
Use the remainder operator to divide by two and check the remainder
a If the remainder is push a
b If the remainder is push a
Set the number to itself divided by two
Go to step
When done converting, use the stack and a StringBuffer to convert the stack contents to a string
Return that string
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
