In the tutorial How to Convert from Decimal to Binary Shortly & Efficiently? we discuss about the converting methods from decimal to binary. In this tutorial, we will discuss this with an example.
Fro example, we would like to convert decimal value 99 to binary. So, the steps are the followings:
Find which weighted value is bigger than 99. And we find 128. So, we have to take the weighted value just before 128 and so the weighted value should be 64. We would put a 1 to that 64 weighted value and subtract 64 from 99 and the final value should be 35.
Now, we get the decimal value 35 and we again need to check which value is greater than that among the weighted values (128,64,32,16,8,4,2,1) and find that 64 is just greater than that. Before 64, the value is 32 and we now need to choose 32 value and put a 1 in the 32 weighted value. Subtract 32 from 35 and the value is 3. Now, in the next step we need to convert decimal value 3.
Again we check which value is just greater than 3 and we get value 4. So, we choose just before 4 and the weighted value is 2 and put a 1 in that weighted field. Subtract 2 from 3 and we get result 1.
Now we need to convert decimal value 1 to binary. We again search which weighted value is just greater than 1 and we find 2. So, we choose 1 as weighted value 1 is just before the value 2 and put 1 in that bit position. Now, subtract 1 from 1, gives result 0. So, we no longer need to find any bit position values.
At last, put 0 all other bits position where we find any blank bits to get the final binary value.
Following the above steps, you can easily convert the decimal value 99 to binary value.
Final result,
- Decimal value = 99
- Binary value = 01100011
No comments:
Post a Comment