All courses / Data Structures and Algorithms for Game Devs / Bits and bytes
Reading binary by hand
Challenge lesson, about 10 min, +20 XP
Convert.ToInt32(text, 2) reads binary for you. In this lesson you write that method yourself, with a loop and nothing else. It takes about ten lines, and once you have written it, the place values stop being a table you look up. You will also see a trick for reading digits that works in any base.
There are two common ways to turn "1011" into 11 by hand.
Read the rest of this lesson and run the code in your browser.