Archive for the ‘Octal’ tag

[002] - Number Conversions across various Number Systems (Part 1)

without comments

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 :

(1101)_2= 1*2^3+1*2^2+0*2^1+1*2^0=(13)_10
(123)_8= 1*8^2+2*8^1+3*8^0=(83)_10
(8C5)_16= 8*16^2+12*16^1+5*16^0=(709)_10

To convert a decimal number, separate the integer and fraction part and convert each part separately. For example:
(456.20)_8= (456)_8+(0.20)_8
(456)_8= 4*8^2+5*8^1+6*8^0=(302)_10
(0.20)_8= 2*8^-1+0*8^0=(0.25)_10
doubleright (456.20)_8= (302.25)_10
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 (41)_10 to binary:

tabular{00000000}{010}{41 ~ 20 1 10 0 5 0 2 1 1 0 0 1}

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,

(41)_10= (101001)_2

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 (0.6875)_10 to its binary equivalent:

tabular{0010101010}{00}{0.6875 ~*2 1.3750 ~*2 0.7500 ~*2 1.5000 ~*2 1.0000}

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,

(0.6875)_10= (0.1011)_2

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.

Written by Rajat

August 10th, 2008 at 7:21 pm

[001] - Number Systems

with 2 comments

In our everyday lives, we use Decimal Numbers whenever we deal with them. That is, we use a number system in which the digits range from 0 to 9 – a total of ten digits (hence the name, decimal). However, there are many number systems that are in existence, and before we define them, let us take a look at the features that define a Number System.

Each Number System has a base, which is determined by the number of digits that make up that system. For example, the decimal number system consists of ten digits; hence, its base is ten. Base is also known as the radix, and is denoted by the letter r.

The value of a number in a number system is interpreted as 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. For example, to interpret the value of the decimal number 465, we may write:

4*10^2+6*10^1+5*10^0

In order to distinguish between various number systems, the digits of the number are enclosed in parenthesis, and its radix is inserted as the subscript. For example, we may write (465)_10 to denote the decimal number 465.

Various Number Systems

As stated before, there are a variety of Number Systems, decimal being one of them. Let us learn about all of them.

Binary Number System

As the title suggests, the Binary system consists of only two digits, 0 and 1. Its radix, therefore, is two. This number system is used in all kinds of electronic devices to perform various computations. To interpret its value, we will write:

100110=1*2^5+0*2^4+0*2^3+1*2^2+1*2^1+0*2^0

Octal Number System

This system has a radix of 8, so the digits range from 0 to 7. Its value is interpreted in pretty same way as the other systems. For example:

465=4*8^2+6*8^1+5*8^0

Hexadecimal Number System

The hexadecimal number system has a radix of 16, and the digits now range from 0 to 9, and afterwards from A to F. Here, A to F represent the decimal 11 to 15. The value of a hexadecimal number will be interpreted like this:

A65D=11*16^3+6*16^2+5*16^1+14*16^0

These are the number systems that exist. My next post in this series will deal with converting numbers from one number system to another.

Written by Rajat

August 10th, 2008 at 12:13 pm