How to convert decimal to octal, we've to find out about both the amount system first. A number with base 8 is that the octal number and variety with base 10 is that the decimal number. Here we'll learn conversion from decimal to octal number. It is the same as converting any decimal number to binary or decimal to hexadecimal.
In decimal to binary, we divide the amount by 2, in decimal to hexadecimal we divide the amount by 16. In the case of decimal to octal conversion method, we divide the amount by 8 and write the remainders within the reverse order to urge the equivalent octal number.
Decimal system is the most familiar number system to the general public. It is the base 10 which has only a total of 10 symbols − 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Whereas the octal system is one of the number systems to represent numbers. It is the base 8 which has only 8 symbols as− 0, 1, 2, 3, 4, 5, 6, and 7.
Conversion from Decimal to Octal Number System
Let’s learn how to convert decimal to octal. There are various direct or indirect methods to convert a decimal number into an octal number( decimal to octal conversion method). In the indirect method, we need to convert the decimal number into other number system (e.g., binary or hexadecimal), then we can convert them into binary numbers by converting each digit into binary numbers from hexadecimal and using grouping from the octal numeration system.
Example − Convert the Decimal Number 98 Into an Octal Number
First convert it into binary or hexadecimal number,
= (1x26 + 1x25 + 0x24 + 0x23+ 0x22 + 1x21+ 0 x 20)10 or (6 x 161+2x160)10
Because the bases of the binary and hexadecimal are 2 and 16 respectively.
Then convert each digit of hexadecimal number into 4 little bits of binary number whereas convert each group of three bits from least significant in binary number.
= (001 100 010)2
or (0110 0010)2
= (001 100 010)2
= (1 4 2)8
But, there are two of the direct methods which are available for converting the decimal number into an octal number − Converting with Remainders and Converting with Division. These are explained as follows below.
(a) Converting With Remainders (for Integer Part)
This is a straightforward method which involves dividing the number to be converted. Let the decimal number be N and then divide this number with 8 because the base of the octal number system is 8. Note down the worth of remainder, which can be − 0, 1, 2, 3, 4, 5, 6, or 7. Again we divide the remaining decimal number until it becomes 0 and note every remainder of the step performed. Then write the remainders from the bottom to the top (or in the reverse order), which will also be equivalent to octal number of given decimal number. This is a procedure for converting an integer decimal number, the algorithm is given below.
Take the decimal number as dividend.
Divide the number by 8 (as 8 is the base of octal so divisor here).
Preserve the remainder in an array (and it will be: 0, 1, 2, 3, 4, 5, 6 or 7 because of the divisor 8).
Repeat the above two steps until the amount is bigger than zero.
Print the mentioned array in the reverse order (which will also be equivalent to the octal number of the given decimal number).
The dividend (here is the given decimal number) is the number here which is also being divided, the divisor (here the base of the octal, i.e., 8) in the number by which the dividend is divided, and the quotient is the result for the division.
Example − To Convert the Decimal Number 210 Into an Octal Number.
As we know the given number is a decimal integer number, so just by using the above algorithm we perform a short division by 8 with the remainder.
Now, we write the remainder from bottom to the top (in the reverse order), this will be 322 which is also the equivalent octal number for the decimal integer 210.
For the decimal fractional part, the method is explained as follows below.
(b) Converting With Remainders (for Fractional Part)
Let the decimal fractional also be a part of M then we multiply this number by 8 because the base for the octal number system is 8. Note down the value of the integer part, which will be − 0, 1, 2, 3, 4, 5, 6, and 7. Again we multiply the remaining decimal fractional number until it becomes 0 and then note the every integer part for the result of every step. After that write the noted results of the integer part, which will be an equivalent fraction octal number of the given decimal number. This is a procedure for converting a fractional decimal number, the algorithm is given below.
Take the decimal number as a multiplication.
Multiply this number by 8 (8 is base of octal so multiplier here).
Store the value of the integer part of the result in an array (it will be: 0, 1, 2, 3, 4, 5, 6, and 7 because of multiplier 8).
Repeat the two of the above steps until and unless the number becomes zero.
Print the array (which are going to be like a fractional octal number to a given decimal fractional number).
Example − Convert the Decimal Fractional Number 0.140869140625 Into an Octal Number.
As we know the given number is a decimal fractional number, so by just using the above algorithm we perform a short multiplication by 8 with the integer part.
Now, we write all these resultant integer parts, and this will be approximately 0.11010 which is also equivalent to the octal fractional number for the decimal fractional 0.140869140625.