What is the mechanism of conversation of decimal to binary? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the mechanism of conversation of decimal to binary?

3rd Jun 2017, 4:36 PM
Siddharth Saraf
5 Answers
+ 4
Conversion for decimal to binary lets take an example let the number be 156 do 156÷2=78 no reminder mark as 0 do 78÷2=39 no reminder mark as 0 do 39÷2=19 reminder=1 mark as 1 do 19÷2=9 reminder=1 mark as 1 do 9÷2=4 reminder=1 mark as 1 do 4÷2=2 reminder=0 mark as 0 do 2÷2=1 reminder=0 mark as 0 since the last result is 1 mark as 1 binary for 156 is 10011100 start from bottom to top( with the values marked)
3rd Jun 2017, 4:54 PM
Gokul Nagarajan
Gokul Nagarajan - avatar
+ 15
@Gokul Nagarajan: To convert binary to decimal: 100101: Go from right to left, under each bit. Put a 2 with an exponent of 0 under the first. Put a 2 with an exponent of 1 under the second. Put a 2 with an exponent of 2 under the third. Continue this from right to left and calculate the value of each. Now, If the bit is a zero, then it has no value. If the bit is a one, then it has the value of whatever number you calculated under it. Add up every bit's value that is one and you will have successfully converted it. 100101 - From right to left: The first bit is 1. Under it, there would be a 2 with an exponent of 0. That is equal to 1. Add it to the sum. The second bit is 0. Move on. The third bit is 1. Under it, there would be a 2 with an exponent of 2. That is equal to 4. Add it to the sum. The fourth bit is 0. Move on. The fifth bit is 0. Move on. The sixth bit is 1. Under it, there would be a 2 with an exponent of 5. That is equal to 32. Add it to the sum. If you check the sum from the example, it will be 37. 1 + 4 + 32 = 37. So 100101 is 37 in binary.
5th Jun 2017, 11:20 AM
Fox
Fox - avatar
+ 15
No problem ^_^ @Gokul
5th Jun 2017, 11:30 AM
Fox
Fox - avatar
+ 5
Thanks @cipher for the method😊😊
5th Jun 2017, 11:28 AM
Gokul Nagarajan
Gokul Nagarajan - avatar
+ 4
sorry i dont know the reverse
3rd Jun 2017, 5:05 PM
Gokul Nagarajan
Gokul Nagarajan - avatar