Question: How can I convert from decimal to binary in C using the successive division by 2 method using only bit manipulation? I know how to
How can I convert from decimal to binary in C using the successive division by 2 method using only bit manipulation? I know how to do this by just writing the code with the division operand / but I want to do it using only bit manipulation.
Successive division method: For example if the decimal number was 156, Id divide by two. You ignore the remainder. If the value of the dividend divided by 2 is an even number then it would be assigned a value of 0, if its odd it would be 1.
Binary
156/2 = 78 0
78/2 = 39 1
39/2 = 19 1
19/2 = 9 1
9/2 = 4 0
4/2 = 2. 0
2/2 = 1 1
Binary value of 156 = 1001110
Write a c program that converts from decimal to binary.
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
