Numbers, or information in general, can be written down in different forms. The most basic one, and the only one that is actually understood by a computer, is a binary. Usually, it is depicted by a sequence of 1s and 0s, but it could be anything really. Anything, that can take two separate states. The once common CDs or DVDs are a sequence of laser burns (tiny pits) in a spiral track (burn - 1, no burn - 0). The hard disk drives store data as magnetized spots, whereas SSD drives cash it as electrons trapped in tiny transistors. The data can be read into memory (RAM) and send to a processor for calculations.
This time you task is to read about the binary numbers, or watch some online videos (e.g. from Khan Academy), on the topic. Next, to get a better grasp of the subject, write:
For simplicity, assume that the functions will operate only on natural numbers in the range of let’s say 0 to 1024 (in decimal). You may check your functions against the built-in string
and parse
functions. For instance, string(3, base=2)
converts the decimal (3) to its binary representation and parse(Int, "11", base=2)
performs the opposite action.