Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

This is an easy question, but I can't explain it lol, how would you guys explain it?

There is a procedure for converting a decimal number to binary in the following way: repeatedly divide the number by 2, writing the quotient and remainder at each step. Stop when 0 is obtained as a quotient. The sequence of remainders, written backwards (from the way they were obtained) is the binary representation. Here is an example, finding the binary representation of 49:

|49 24 1 |

|24 12 0 |

|12 6 0 |

|6 3 0 |

|3 1 1 |

|1 0 1 |

So 49 = 110001 (base 2) - Explain why this method works.

share|improve this question
    
Do you want to know why it works or the details of how it works? –  Thomas Jun 1 '12 at 4:04
    
either way is good :) –  hihello4 Jun 1 '12 at 4:16
    
Did my answer help? –  Thomas Jun 1 '12 at 4:49
    
Sorry, I can't find how this relates to cryptography, the topic of this site. –  Paŭlo Ebermann Jun 1 '12 at 7:26
add comment

closed as off topic by fgrieu, Paŭlo Ebermann Jun 1 '12 at 7:25

Questions on Cryptography Stack Exchange are expected to relate to cryptography within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

In base 10 we write for example $133$ when we mean $$133 = 1 * 10^2 + 3*10^1 + 3*10^0. $$ If we want to write $49$ in base $2$ then note first that: $$49 = 1*2^5 + 1*2^4 + 0*2^3 + 0*2^2 + 0*2^1 + 1*2^0. $$ Because of this $49$ is $110001$.

Noe obviously, you "don't know this", but I wanted to write it down so that you can see what happens as you divide by two.

So you want to find the digits in base you, you could start by dividing $49$ by $2$. You get a remainder of $1$ because $49$ is odd. Hence you know that the coefficient in from of $2^0$ is one. You subtract that reminder and divide by $2$. Dividing by $2$ decreases all the exponents by one, so $$24 = 1*2^4 + 1*2^3 + 0*2^2 + 0*2^1 + 0*2^0. $$ Now you just continue like this dividing by $2$ to find the coefficient infront of $2^0$ (which then is the coefficient in front of $2^1$ in $49$).

Maybe this is all too many words...

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.