Number System
Conversions:
Now
it is the time for understanding the number system conversion i.e. Decimal to
Binary, Binary to Hexadecimal and Hexadecimal to decimal and vice versa.
Before we
learn the conversion process, let us have a look at the Binary, Decimal and
Hexadecimal numbers.
Binary Number:
The
Binary numeral system represents numeric values using two symbols: 0 and 1. This
is directly implemented in digital electronic circuits using logic gates. Now
the binary system is used internally by almost all the modern computers and
computer based devices.
Binary
numbers are read digit by digit to differentiate them from the decimal
numbering system. For example, 100 is read as one zero zero.
Since
the binary numbering system has only two symbols, its base is 2. So this
numbering system is also called as Base2 numbering system.
Decimal Number:
The
Decimal numbering system represents numeric values using ten symbols:
0,1,2,3,4,5,6,7,8,9.
Since
the decimal numbering system has ten symbols, its base is 10. So this numbering
system is also called as Base10 numbering system.
Hexadecimal Numbers:
The
Hexadecimal number system represents numeric values using 16 symbols: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
This numbering system is commonly used to represent the hardware address of the
NIC card i.e. MAC addresses.
It
is also referred as Base 16 number system.
Number system Conversion:
This
knowledge will also be helpful for understanding IP address & Sub-netting.
To avoid confusion while using
different numbering systems, the base of each individual number may be
specified by writing it as a subscript of the number. For example, the binary
number 10011100 may be specified as "base two" by writing it as
100111002.
The decimal number 156 may be
written as 15610 and read as "one hundred fifty-six, base
ten".
The Hexadecimal number 156 can be
written as 15616 or 0x156 and read as "one hundred fifty-six,
base 16".
Binary to Decimal Conversion:
Let’s
take a binary number 100 (One zero zero) and convert it to decimal number.
(100)2 = --------?
In order to get the decimal value
of a given binary number, we just need to multiply each digit with the power of
two starting at 0 from the right hand side. And finally add the values in each
position.
Computers and networking
components process everything in binary. And we know that:
1Byte = 8 bits
While learning IP addressing and
sub-netting, we might need to convert a 1byte binary value to decimal value. So
let us see how to do it:
Whatever
the value we might take in binary, in order to convert that value to decimal
value we just need to multiply each digit with power of 2, beginning from right
hand side. And add the digit position values, as we did above.
So
if there are 8 bits (1 Byte), e.g.: B B B B B B B B then we multiply each digit with the power of
2:
So if you’ve observed carefully
we are just adding values of power of 2, wherever the bit value is 1.
This simple is converting a 1
byte binary value to a decimal value. The only thing we need to remember is the
values of power of 2, in the positions.
So if all the bits are having a
value of 1, then the resulting decimal number will be 255.
Let’s check it out:
One more thing to remember is the
right most bit in byte is called as LSB (Least Significant Bit) and the
leftmost bit is called as MSB (Most Significant Bit).
Decimal to Binary:
To
convert a decimal number to binary, we just need to divide the decimal number
with 2 (Base of binary number) until we get a Quotient of 1.
Now coming to our 1byte value (8 bits):
Let
us see how to convert a given decimal value to an 8 bit binary value. (Remember
that we can convert a decimal number to 8bit binary value if and only if it is
less than 255, since it is maximum value of an 8bit binary number as we’ve seen
above.)
So if we need to convert 125 into
8bit binary value, here are the steps:
Few points to be remembered
before we continue with the conversion process, they are: We must remember the
bit position values of power of 2. The values are:
Now the value of decimal 125 in
binary is: (01111101)2 or (1111101)2.
If you’ve observed carefully, we
are just putting a 1 in the bit position wherever the bit position value can be
subtracted from the given number or the remaining number after subtraction. And
wherever the bit position is not subtractable, we are putting a 0(zero).
Binary to Hexadecimal:
The
hexadecimal numbers are most commonly used in digital systems because a single hexadecimal
value can represent 4 binary digits nothing but a nibble. The relationship can
be understood with the formula: 24 = 16.
The
hexadecimal numbers can be used to write the large number of binary numbers
with much fewer digits.
The
below table is used to convert a binary number to hexadecimal, and hexadecimal
number to binary number.
Hexadecimal to Binary:
Again
the same table will be used to convert an hexadecimal value to a binary number.
E.g.: (A9F3)16 = (----)2
Step1: Go to the above table and
write the value of each hexadecimal digit with the corresponding four digit
binary number.
So the binary value of the given
hexadecimal number is: (1010100111110011)2.
Decimal to Hexadecimal:
To
convert a value from Decimal to Hexadecimal, we first need to convert the
decimal value to binary and then convert the binary to hexadecimal.
E.g. (1152)10 = (----)16
Step1: Convert the 1152 decimal
to binary. Nothing but we should divide the given number by 2 until we are left
with a Quotient of 1.
Hexadecimal to Decimal:
To
convert a value from Hexadecimal to Decimal, we first need to convert the Hexadecimal
value to binary and then convert the binary to decimal.
E.g.: (F3D5B)16
Step4: Add the values:
Upon
adding the values we will get a value: (998747)10.
This is how we convert the values
from one numbering system to other. However we will find the most use of the
conversion between decimal to binary.
In the next post we will discuss
about IP (Internet Protocol) addresses.
No comments:
Post a Comment