Hints for Binary Conversion

The biggest hint is that building the binary string should work from right to left, because the rightmost bit is always the ones column, while the leftmost bit's value changes depending on how many digits the numeral has.

The following exercises are hints; use as many or few as you need.

Remember, the input to your block is a number, so you do arithmetic on it; the value reported by your block is a text string, so you need string operators (like join) to make it.

Talk with Your Partner
    Try doing these calculations by hand, and look for connections. The connections may help you understand how to write your code.
  1. Explain why 13 is 1101 in binary.
  2. Write 26 in binary. Write 27 in binary. How is each related to writing 13 in binary?
  3. What are the quotient and remainder when you divide 27 by 2?
Remember, you'll want to use the quotient and mod blocks except that, for binary, you need a quotient and remainder when dividing by 2, not 5.