In Unit 4 you learned about the binary representation of a number. In this project, you'll write a reporter decimal->binary
that takes a number (which Snap! represents in decimal) as input, and reports a string of zeros and ones that represent the same number in binary:
To solve this problem, you'll need to work with integer division into a quotient and remainder. For example, 17 รท 5 is 3 with a remainder of 2. Here's how to find the quotient and remainder in Snap! :
floor
you'll need the sqrt
block, then change the operation. The floor of a number is the largest integer less than or equal to that number. The floor of π is 3.decimal->binary
block. If you're stuck after trying as many ideas as you can think of, go to this page for some help.