Decimal to Binary,Octal and Hexadecimal
CONVERSION FROM
DECIMAL TO BINARY, OCTAL, HEXADECIMAL
A decimal number has two
parts—integer part and fraction part. For example, in the decimal number
23.0786, 23 is the integer part and .0786 is the fraction part. The method used
for the conversion of the integer part of a decimal number is different from the
one used for the fraction part. In the following subsections, we shall discuss
the conversion of decimal integer, decimal fraction and decimal
integer.fraction number into binary, octal and hexadecimal number.
Converting Decimal Integer to Binary, Octal, Hexadecimal
A decimal integer
is converted to any other base, by using the division operation. To convert a
decimal integer to—
·
binary-divide
by 2,
·
octal-divide
by 8, and,
·
hexadecimal-divide
by 16.
Let us now understand this
conversion with the help of some examples.
Example 1: Convert 25 from Base 10 to
Base 2.
1.
Make a table as shown below. Write the number in
centre and toBase on the left side.
to Base Number Remainder
(Quotient)
2 25
to Base Number Remainder
(Quotient)
2
|
25
|
|
2
|
12
|
1
|
2
|
6
|
0
|
2
|
3
|
0
|
2
|
1
|
1
|
0
|
1
|
3.
Write the digits in remainder column starting from downwards
to upwards,
|
The binary equivalent of number (25)10 is (11001)2
The steps shown above are
followed to convert a decimal integer to a number in any other base.
Example 3: Convert 147 from Base 10 to Base 2, 8 and 16.
Example 4: Convert 94 from Base 10 to Base 2, 8 and 16.
Converting Decimal Fraction to Binary, Octal, Hexadecimal
A fractional number is a number
less than 1. It may be .5, .00453, .564, etc. We use the multiplication
operation to convert decimal fraction to any other base.
To convert a decimal fraction to—
·
binary-multiply
by 2,
·
octal-multiply
by 8, and,
·
hexadecimal-multiply
by 16.
Steps for conversion of a decimal fraction to any other base are—
1.
Multiply the fractional number with the to Base, to get a resulting number.
2.
The resulting number has two parts,
non-fractional part and fractional part.
3.
Record the non-fractional part of the resulting number.
4.
Repeat the above steps at least four times.
5.
Write the digits in the non-fractional part
starting from upwards to downwards.
Example 5: Convert 0.2345 from Base 10
to Base 2.
The binary equivalent of (0.2345)10 is (0.001111)2
|
Converting Decimal Integer.Fraction to Binary, Octal,
Hexadecimal
Comments
Post a Comment