- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to Convert Decimal to Octal?

**Decimal** system is most familiar number system to the general public. It is base 10 which has only 10 symbols − 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Whereas **octal** system is one of the number systems to represent numbers. It is base 8 which has only 8 symbols − 0, 1, 2, 3, 4, 5, 6, and 7.

## Conversion from Decimal to Octal number system

There are various direct or indirect methods to convert a decimal number into octal number. In an indirect method, you need to convert a decimal number into other number system (e.g., binary or hexadecimal), then you can convert into binary number by converting each digit into binary number from hexadecimal and using grouping from octal number system.

**Example** − Convert decimal number 98 into octal number.

First convert it into binary or hexadecimal number, = (98)_{10}= (1x2

^{6}+1x2^{5}+0x2^{4}+0x2^{3}+0x2^{2}+1x2^{1}+0x2^{0})_{10}or (6x16^{1}+2x16^{0})_{10}Because base of binary and hexadecimal are 2 and 16 respectively. = (1100010)_{2}or(62)_{16}Then convert each digit of hexadecimal number into 4 bit of binary number whereas convert each group of 3 bits from least significant in binary number. = (001 100 010)_{2}or(0110 0010)_{2}= (001 100 010)_{2}= (1 4 2)_{8}= (142)_{8}

However, there are two direct methods are available for converting a decimal number into octal number − Converting with Remainders and Converting with Division. These are explained as following below.

## (a) Converting with Remainders (For integer part)

This is a straightforward method which involve dividing the number to be converted. Let decimal number is N then divide this number from 8 because base of octal number system is 8. Note down the value of remainder, which will be − 0, 1, 2, 3, 4, 5, 6, or 7. Again divide remaining decimal number till it became 0 and note every remainder of every step. Then write remainders from bottom to up (or in reverse order), which will be equivalent octal number of given decimal number. This is procedure for converting an **integer decimal** number, algorithm is given below.

Take decimal number as dividend.

Divide this number by 8 (8 is base of octal so divisor here).

Store the remainder in an array (it will be: 0, 1, 2, 3, 4, 5, 6 or 7 because of divisor 8).

Repeat the above two steps until the number is greater than zero.

Print the array in reverse order (which will be equivalent octal number of given decimal number).

Note that dividend (here given decimal number) is the number being divided, the divisor (here base of octal, i.e., 8) in the number by which the dividend is divided, and quotient (remaining divided decimal number) is the result of the division.

**Example** − Convert decimal number 210 into octal number.

Since given number is decimal integer number, so by using above algorithm performing short division by 8 with remainder.

Division | Remainder (R) |
---|---|

210 / 8 = 26 | 2 |

26 / 8 = 3 | 2 |

3 / 8 = 0 | 3 |

Now, write remainder from bottom to up (in reverse order), this will be 322 which is equivalent octal number of decimal integer 210.

But above method can not convert fraction part of a mixed (a number with integer and fraction part) octal number. For **decimal fractional** part, the method is explained as following below.

## (b) Converting with Remainders (For fractional part)

Let decimal fractional part is M then multiply this number from 8 because base of octal number system is 8. Note down the value of integer part, which will be − 0, 1, 2, 3, 4, 5, 6, and 7. Again multiply remaining decimal fractional number till it became 0 and note every integer part of result of every step. Then write noted results of integer part, which will be equivalent fraction octal number of given decimal number. This is procedure for converting an **fractional decimal** number, algorithm is given below.

Take decimal number as multiplicand.

Multiple this number by 8 (8 is base of octal so multiplier here).

Store the value of integer part of result in an array (it will be: 0, 1, 2, 3, 4, 5, 6, and 7 because of multiplier 8).

Repeat the above two steps until the number became zero.

Print the array (which will be equivalent fractional octal number of given decimal fractional number).

Note that a multiplicand (here decimal fractional number) is that to be multiplied by multiplier (here base of octal, i.e., 8)

**Example** − Convert decimal fractional number 0.140869140625 into octal number.

Since given number is decimal fractional number, so by using above algorithm performing short multiplication by 8 with integer part.

Multiplication | Resultant integer part |
---|---|

0.140869140625 x 8=0.12695313 | 1 |

0.12695313 x 8=0.01562504 | 1 |

0.01562504 x 8=0.12500032 | 0 |

0.12500032 x 8=0.00000256 | 1 |

0.00000256 x 8=0.000020544 | 0 |

and so on .... |

Now, write these resultant integer part, this will be approximate 0.11010 which is equivalent octal fractional number of decimal fractional 0.140869140625.

## Converting with Division

This method is guessing octal number of a decimal number. You need to draw a table of power of 8, For **integer part**, The algorithm is explained as following below.

Start with any decimal number.

List the powers of 8.

Divide the decimal number by the largest power of eight.

Find the remainder.

Divide the remainder by the next power of 8.

Repeat until you've found the full answer.

**Example** − Convert decimal number 136 into octal number.

According to above algorithm, table of power of 8,

Decimal | 8^{2}=64 | 8^{1}=8 | 8^{0}=1 |

Octal | 2 | 1 | 0 |

Divide the decimal number by the largest power of eight. = 136 / 64 = 2.125 So 2 will be first digit or most significant bit (MSB) of octal number. Now, remainder will be, = 136 - 642 = 8 Now, divide this remainder by the next power of 8. = 8 / 8 =1.0 So 1 will be next digit or second most significant bit (MSB) of octal number. Now, remainder will be, = 8 - 81 = 0 Now, divide this remainder by the next power of 8. = 0 / 8 = 0 So, 0 will be last (least significant) bit of required octal number. Therefore, 210 will be equivalent octal number of given decimal number 136.

- Related Questions & Answers
- Java Program to convert Decimal to Octal
- How to convert a Decimal to Octal using C#?
- Convert decimal integer to octal in Java
- C# program to convert decimal to Octal number
- C++ Program to convert Decimal Numbers to Octal
- Convert octal number to decimal number in Java
- Java program to convert decimal number to octal value
- Java program to convert float decimal to Octal number
- Python program to convert float decimal to octal number
- Java Program to convert octal number to decimal number
- Java Program to convert decimal integer to octal number
- How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?
- C++ Program to convert Octal Number to Decimal and vice-versa
- How to Convert Binary to Octal?
- How to Convert Octal to Binary?