Base 10 to Base 2

Kris Sparks
1 min readFeb 5, 2018
Anaerobic Membrane Bioreactor for Continuous Lactic Acid Fermentation

Computers only know binary. Base 2 is binary. Let’s convert a couple of integers to their binary representation.

The number 10.

n = 10

n/2 = 5 with a remainder of 0, so the last number in our binary string is 0.

0

Now n=5

n/2 is 2 with a remainder of 1.

So our second to last number is 1.

10

Now n = 2

n/2 = 1 with a remainder of 0

So our third to last number is 0.

010

And that leaves us with 1, which is our first number

1010

Another representation of what we just did:

n | / | quotient | remainder
----------------------------
10 2 5 0
5 2 2 1
2 2 1 0
1
result = 1010

Let’s try 7!

n | / | quotient | remainder
----------------------------
7 2 3 1
3 2 1 1
1
result = 111

There are converters that will do this for us, but math is fun and it is important to know how and why things work.

--

--