DLD Lecture # 01
DLD Lecture # 01
Lecture # 01
Decimal numbers are represented in base 10, but the binary numbers are of base 2.
Hence, to convert a decimal number to binary number, the base of that number is to
be changed. Follow the steps given below:
Step 1: Divide the Decimal Number with the base of the number system to be
converted to. Here the conversion is to binary, hence the divisor will be 2.
Step 2: The remainder obtained from the division will become the least significant
digit of the new number.
Step 3: The quotient obtained from the division will become the next dividend and
will be divided by base i.e. 2.
Step 4: The remainder obtained will become the second least significant digit i.e. it
will be added in the left of the previously obtained digit.
Now, the steps 3 and 4 are repeated until the quotient obtained becomes 0, and the
remainders obtained after each iteration are added to the left of the existing digits.
After all the iterations are over, the last obtained remainder will be termed as the
Most Significant digit.
Decimal to Octal Conversion
Octal Numbers are represented in base 8. Hence, to convert a decimal
number to octal number, the base of that number is to be changed. Follow
the steps given below:
Step 1: Divide the Decimal Number with the base of the number
system to be converted to. Here the conversion is to octal, hence the
divisor will be 8.
Step 2: The remainder obtained from the division will become the least
significant digit of the new number.
Step 3: The quotient obtained from the division will become the next
dividend and will be divided by base i.e. 8.
Step 4: The remainder obtained will become the second least
significant digit i.e. it will be added in the left of the previously obtained
digit.
Now, the steps 3 and 4 are repeated until the quotient obtained
becomes 0, and the remainders obtained after each iteration are added
to the left of the existing digits.
Decimal to Hexadecimal Conversion