# Binary to Decimal

Binary numbers have been used since ancient times, but they weren't well understood until the 19th century. Binary is a base 2 system, which means there are only two possible values for each digit: 0 and 1. In contrast, our more familiar base 10 system has ten possible values for each digit: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

To convert from binary to decimal, we can use a simple method known as "long division". We divide the binary number by 2 (10 in decimal), and write down the remainder. We then repeat the process with the quotient (the number we originally divided), this time dividing by 2 again. We continue doing this until we reach a quotient of 0.

For example, let's convert the binary number 10011 (19 in decimal) to decimal using long division. We divide 19 by 2, and write down the remainder (1):

1) 10011 ÷ 2 = 10011 with a remainder of 1

To find the next digit in the answer, we take the quotient (10011) and divide it by 2 again. This time we get a remainder of 0:

2) 10011 ÷ 2 = 1000 with a remainder of 0

We continue dividing the quotients by 2 until we get a quotient of 0:

3) 1000 ÷ 2 = 100 with a remainder of 0

4) 100 ÷ 2 = 10 with a remainder of 0

5) 10 ÷ 2 = 1 with a remainder of 0

6) 1 ÷ 2 = 0 with a remainder of 1

We can now read off the answer from the remainders: the first digit is the last remainder we calculated (1), the second digit is the second-last remainder (0), and so on. So in this case, the answer is 11001 in decimal (25).

It's worth noting that the binary number 10011 is not a multiple of 2, so the answer will always have a remainder of 1 when we divide by 2. In general, if we're converting a binary number that is a multiple of 2, the answer will have a 0 in the same position (for example, 101000 (40) converts to 1000 (8), and 1000000 (64) converts to 100000 (32)).

Converting from decimal to binary works in a similar way. We divide the decimal number by 2, and write down the remainder. We then take the quotient and repeat the process, this time dividing by 2 again. We continue doing this until we reach a quotient of 0.

For example, let's convert the decimal number 25 to binary using long division. We divide 25 by 2, and write down the remainder (1):

1) 25 ÷ 2 = 12 with a remainder of 1

To find the next digit in the answer, we take the quotient (12) and divide it by 2 again. This time we get a remainder of 0:

2) 12 ÷ 2 = 6 with a remainder of 0

We continue dividing the quotients by 2 until we get a quotient of 0:

3) 6 ÷ 2 = 3 with a remainder of 0

4) 3 ÷ 2 = 1 with a remainder of 1

5) 1 ÷ 2 = 0 with a remainder of 1

We can now read off the answer from the remainders: the first digit is the last remainder we calculated (1), the second digit is the second-last remainder (0), and so on. So in this case, the answer is 10011 in binary (19).

It's worth noting that the decimal number 25 is not a multiple of 2, so the answer will always have a remainder of 1 when we divide by 2. In general, if we're converting a decimal number that is a multiple of 2, the answer will have a 0 in the same position (for example, 8 (1000) converts to 1000 (40), and 32 (100000) converts to 100000 (64)).

Binary numbers have a number of useful properties. For example, they're easy to add and subtract using the "carry" method that we learned in elementary school. They're also easy to multiply and divide by 2 (which is why they're used so often in computer systems).

Another useful property of binary numbers is that they can be easily converted to and from hexadecimal numbers. Hexadecimal is a base 16 system, which means each digit can have 16 different values (0-9 and A-F). This makes it particularly convenient for representing binary data, since each byte (8 bits) can be represented with two hexadecimal digits.

To convert a binary number to hexadecimal, we can group the bits into nibbles (4-bit chunks) and convert each nibble separately. For example, the binary number 10011010001 (729 in decimal) can be grouped as follows:

1001 1010 0001

We can then convert each nibble to hexadecimal separately:

9 A 1

So the final answer is 9A1 in hexadecimal.

To convert a hexadecimal number to binary, we simply expand each digit into its 4-bit binary equivalent. For example, the hexadecimal number 9A1 can be expanded as follows:

9 A 1

1001 1010 0001

So the final answer is 10011010001 in binary (729 in decimal).

Binary numbers are used extensively in computer systems. Most notably, they're used to represent data in memory and on disk. They're also used to represent numbers in various formats, such as fixed-point and floating-point. Finally, they're used in many networking protocols for error detection and correction.