# Conversion of Decimal Number System into Octal Number System

Here, we are going to learn **how to convert Decimal Number System into Octal Number System?**

Submitted by Saurabh Gupta, on October 12, 2019

**Converting a number from Decimal to Octal** is almost similar to converting Decimal into Binary, although just one difference is that unlike Binary conversion, here in an integral part, we successively divide the number by 8 until the quotient is 0 (the last remainder becomes the MSB). The remainders read from bottom to top give the equivalent octal integer number. and in the fractional part, we multiply it by 8 till the fractional part of the product is 0. The first integer in the product term gives the MSB, thus the integers read from top to bottom gives the equivalent octal fraction.

Same as in decimal to binary conversion, to **convert a mixed decimal number into octal**, we first separate the integral and the fractional part and then convert them into octal individually, after converting both to octal separately, we combine them back together to get the desired result.

**Example 1:**

**Convert (73.625) _{10} to ( ? )_{8}**

**Solution:**

Firstly, we will separate the integral part (73)_{8} and the fractional part (0.625)_{8}. Now, we will convert each of them to octal individually.

**Integral Part**

Divisor | Quotient | Remainder |
---|---|---|

8 | 73 | |

8 | 9 | 1 LSB |

8 | 1 | 1 |

8 | 0 | 1 MSB |

All the remainders read from top to bottom, where topmost is the LSB and bottom one is the MSB.

**Therefore, (73) _{10} = (111)_{8}**

**Fractional Part**

0.625 * 8 = 5.000

The integer part of the product term read from top to bottom forms the equivalent octal number i.e., **(.625) _{10} = (0.5)_{8}**

After converting both integral part and fractional part individually into octal, now we combine both to get our desired result i.e., **(73.625) _{10} = (111.5)_{8}**

**Example 2:**

**Convert (965.198) _{10} to ( ? )_{8}**

**Solution:**

**Integral Part**

Divisor | Quotient | Remainder |
---|---|---|

8 | 965 | |

8 | 120 | 5 LSB |

8 | 15 | 0 |

8 | 1 | 7 |

8 | 0 | 1 MSB |

The remainders read from bottom to top gives the equivalent octal number i.e., **(965) _{10} = (1705)_{8}**.

**Fractional Part**

0.198 * 8 = 1.584 MSB 0.584 * 8 = 4.672 0.672 * 8 = 5.376 0.376 * 8 = 3.008 0.008 * 8 = 0.064 0.064 * 8 = 0.512 LSB

The integer part of the product term read from top to bottom forms the equivalent octal number i.e., **(0.198) _{10} = (0.145300)_{8}**.

After converting both integral part and fractional part individually into octal, now we combine both to get our desired result i.e., **(965.198) _{10} = (1705.145300)_{8}**

**Example 3:**

**Convert (296.225) _{10} to ( ? )_{8}**

**Solution:**

**Integral Part**

Divisor | Quotient | Remainder |
---|---|---|

8 | 296 | |

8 | 37 | 0 LSB |

8 | 4 | 5 |

8 | 0 | 4 MSB |

The remainders read from bottom to top gives the equivalent octal number i.e., **(296) _{10} = (450)_{8}**.

**Fractional Part**

0.225 * 8 = 1.80 MSB 0.80 * 8 = 0.64 0.64 * 8 = 5.12 0.12 * 8 = 0.96 0.96 * 8 = 7.68 LSB

The integer part of the product term read from top to bottom forms the equivalent octal number i.e., **(0.198) ^{10} = (0.10507)^{8}**.

After converting both integral part and fractional part individually into octal, now we combine both to get our desired result i.e., **(296.225) _{10} = (450.10507)_{8}**.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.