**Decimal System**, which consists of ten different numbers:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

The

**Binary System**is very much used in computational world, the computor, to represent the

**bit**encoded data. This numeral system only consists of 2 numbers :

0 and 1

Converting the binary to decimal

It's easier if I just put an example of this.

But before we start, to indicate the different system, usually the number has a subscript thingy so we won't be confused between those two.

Like so: 1001

_{2}or 11001

_{2}for

**binary**numbers, and 1024

_{10}or 2357

_{10}for

**decimal**.

Example converting binary to decimal

**101**_{2}= (**1**x 2^{2}) + (**0**x 2^{1}) + (**1**x 2^{0})

**101**_{2}= (**4**+**0**+**1**)_{10}

**101**_{2}=**5**_{10}**11101**_{2}= (**1**x 2^{4}) + (**1**x 2^{3}) + (**1**x 2^{2}) + (**0**x 2^{1}) + (**1**x 2^{0})

**11101**_{2}= (**16**+**8**+**4**+**0**+**1**)_{10}

**11101**_{2}=**29**_{10}

So the binary number ofis equal to**11101**in decimal numeral system.**29**

**1000**_{2}= (**1**x 2^{3}) + (**0**x 2^{2}) + (**0**x 2^{1}) + (**0**x 2^{0})

**1000**_{2}= (**8**+**0**+**0**+**0**)_{10}

**1000**_{2}=**8**_{10}

So the binary number ofis equal to**1000**in decimal numeral system.**8**

So the binary number of

*is equal to*

**101***in decimal numeral system.*

**5**Have you noticed the pattern? Each digit of the binary number is an increasing power of 2, starts from the rightmost to the leftmost. So, the last (rightmost) binary digit is multiplied by 2

^{0}, then move to the left binary number, and the exponent is increased by one.

Converting decimal to binary

This is the reversed method of the example above.

For instance:

We want to convert the decimal numberTo do that, we7(7_{10}) to binary.

*iteratively*divide that number with

**2**and use the

__remainder__as the

__binary digit__.

I put a picture of the solution for that:

The first remainder is as the ending digit, and the last will be placed at the starting of the binary digit. So,

**7**

_{10}=

**111**

_{2}.

Another example:

18_{10}= (..?..)_{2}

**10010**. So

**18**

_{10}=

**10010**

_{2}

That's about it.

- The image of
**Leibniz**is under*Wikimedia Commons*. - I made a simple converter of Hexadecimal, Binary, and Decimal on Port Raptor using
`parseInt()`

, and`toString()`

.

## No comments:

## Post a Comment

Tell me what you think...