[002] - Number Conversions across various Number Systems (Part 1)
Numbers are represented using a variety of number systems, including Binary, Octal, Decimal, and Hexadecimal. However, they can be easily converted from one number system to another using simple procedures. In this post, I shall discuss how to achieve this.
One of the most important number conversions is converting a number to its decimal equivalent, and it is achieved by taking the sum of the face values of various digits multiplied by the radix
raised to the power of the index of the digit, starting from right. Yes, interpreting the value of a number is same as converting it into decimal form. For example :



To convert a decimal number, separate the integer and fraction part and convert each part separately. For example:



Conversion from Decimal Numbers to Binary, Octal and Hexadecimal Numbers
The conversion from decimal to binary is done by repetitive division by 2 (the radix of binary). The procedure is simple - Take the binary number, divide it by 2, note the remainder, and divide the quotient again by 2. Continue until you get a zero as the quotient. Now, take the remainders, starting from the latest - stack them one after another and you get the binary number! Lets convert
to binary:

The elements in the second column contain the remainders obtained after repeated division by 2. Stack these remainders together, starting from down, to get the binary equivalent. Hence,

To convert a fractional decimal part to a fractional binary part, we repeatedly multiply the fractional decimal part by two, until we get 1.0 as the result. Remember, only the fractional part is to be multiplied by 2. As an example, lets convert
to its binary equivalent:

Here, the binary equivalent is obtained by stacking together the digits on the LHS of the decimal starting from the top. The first zero is ignored. Hence,

Hence, this is the way Decimal Numbers are converted to their Binary equivalents.
In order to convert Decimal Numbers to their Octal equivalents, replace 2 with 8 in the above calculations. Similarly, replace 2 with 16 for converting Decimal to Hexadecimal.
P.S. - My next post will deal with other conversions that are possible.










