Convert a decimal number to an octal

Author: Eugene Taylor
Date Of Creation: 12 August 2021
Update Date: 1 July 2024
Anonim
Decimal to Octal Conversion
Video: Decimal to Octal Conversion

Content

Octal is the base 8 number system, using only the digits 0 through 7. The biggest advantage is the ease with which you convert to the binary system (base 2), because each digit can be written in an octal as a unique three digit binary number. Converting from decimal to octal is a bit more difficult, but you don't need more math than long division. Start with the division method, where you determine each number by dividing it by powers of 8. The rest method is faster and uses the same calculation method, but can be a bit trickier to understand.

To step

Method 1 of 2: Conversion by sharing

  1. Use this method to learn the concepts. Of the two methods on this page, this method is the easiest to understand. If you are already used to working with different number systems, try the rest method below which is a bit faster.
  2. Write down the decimal number. For this example, we'll convert the number 98 to an octal.
  3. List the powers of 8. Remember that "decimal" has a base of 10 because every digit of a number within this system is a power of 10. We call the first 3 digits the units, tens and hundreds - but we can also write 10, 10 and 10. Octal numbers, or those with a base 8, use powers of 8 instead of 10. Write some of these powers of 8 on a horizontal line, from largest to smallest. Note that all these numbers are written as decimal (base 10):
    • 8  8  8
    • Rewrite this as:
    • 64  8  1
    • You don't need powers of 8 greater than your original number (98 in this case). Since 8 = 512 and 512 is greater than 98, we can leave it out of the table.
  4. Divide the decimal number by the number with the greatest power of 8. Take a good look at the decimal number: 98. The nine in the tens place indicates that there are 9 tens in this number. 10 goes into this number 9 times. Likewise, with the octal, we want to know how many times the "64" goes into the final number. Divide 98 by 64 to find this out. The easiest way to do this is to use a table, read from top to bottom:
    • 98
      ÷
    • 64   8   1
      =
    • 1 ← This is the first digit of your octal number.
  5. Determine the rest. Calculate the remainder of the subproblem, or the number that remains and no longer fits entirely. Write your answer at the top of the second column. This is what is left of your number after the first number is calculated. In our example, 98 ÷ 64 = 1. Since 1 x 64 = 64, the remainder is 98 - 64 = 34. Add this to your table:
    • 98   34
      ÷
    • 64   8   1
      =
    • 1
  6. Divide the remainder by the next power of 8. To determine the next digit, we proceed with the next power of 8. Divide the remainder by this number and complete the second column of your table:
    • 98   34
      ÷     ÷
    • 64   8   1
      =    =
    • 1    4
  7. Keep doing this until you find the full answer. As before, you determine the rest of your answer and write it down at the top of the next column. Keep dividing and determining the remainder until you've done this for each column, including 8 (the units). The last row is the last decimal number converted to an octal. Here is our example with the fully completed table (note that 2 is the remainder of 34 ÷ 8):
    • 98   34   2
      ÷     ÷    ÷
    • 64   8   1
      =    =    =
    • 1    4    2
    • The final answer: 98 with base 10 = 142 with base 8. You can write this as 9810 = 1428
  8. Check your work. You do this by multiplying each digit of the octal by the power of 8 it represents. You should then get the original number again. Let's check the answer, 142:
    • 2 x 8 = 2 x 1 = 2
    • 4 x 8 = 4 x 8 = 32
    • 1 x 8 = 1 x 64 = 64
    • 2 + 32 + 64 = 98, which is the number we started with.
  9. Try the following practice problem. Practice the method by converting 327 to an octal number. When you think you have found the answer, select the invisible text below to see the effect of the complete problem.
    • Select this piece:
    • 327  7   7
      ÷     ÷    ÷
    • 64   8   1
      =    =    =
    • 5    0    7
    • The answer is 507.
    • (Hint: 0 may be the answer to a partial problem.)

Method 2 of 2: Conversion by using the rest

  1. Start with a decimal number. We start with the number 670.
    • This method is faster than consecutive sharing. Most people find this a lot more difficult to understand, and may prefer to start with the simpler method above.
  2. Divide this number by 8. Ignore the decimal places for now. You will soon see why this calculation is useful.
    • In our example: 670 ÷ 8 = 83.
  3. Determine the rest. Now that we've "divided by 8" as many times as we can, there's a little remainder. This is it last digit of our octal number, in the place of the units (8). The remainder is always less than 8, so it can be represented by any of the other digits.
    • In our example: 670 ÷ 8 = 83 remainder 6.
    • Our octal number so far is ??? 6.
    • If your calculator has a "modulus" or "mod" button, you can determine this value by entering: "670 mod 8."
  4. Divide the answer to the division problem by 8. Keep the rest aside and return to the division problem. Take the answer and divide it again. 8. Write down the answer and determine the rest. This is the second to last digit of the octal, the 8 = 8s place.
    • In our example: The answer to the last sub-problem is 83.
    • 83 ÷ 8 = 10 remainder 3.
    • Our octal number so far is ?? 36.
  5. Divide by 8 again. As before, divide the answer to the last sub-problem by 8 and determine the rest. This is the third last digit of the octal, the 8 = 64 place.
    • In our example: The answer to the last sub-problem is 10.
    • 10 ÷ 8 = 1 remainder 2.
    • Our octal number so far is? 236.
  6. Repeat this until you have determined the last digit. If you have calculated the last sub-problem, the answer is zero. The rest of this problem is the first digit of the octal. You have now completely converted the decimal number.
    • In our example: The answer to the last sub-problem is 1.
    • 1 ÷ 8 = 0 remainder 1.
    • Our final answer is the octal number 1236. We can write this as 12368 to show that this is an octal number.
  7. Understand how this works. If you find it difficult to understand this method, here is an explanation:
    • You start with a stack of 670 units.
    • The first subproblem divides this into groups, 8 units per group. What's left, the rest, doesn't fit the octal eight spot. So it must be in the place of the units.
    • Now you take the stack of groups and divide it into sections of 8 groups each. Each section now has 8 groups with 8 units each, or 64 units in total. The rest does not fit in here, so it does not belong in the place of the 64s. It has to be in the 8's place.
    • This continues until you have determined the whole number.

Practice exercises

  • Try converting the following decimal numbers yourself using one of the above methods. When you think you've found the answer, select the invisible text to the right of the equal sign to check. (Note that 10 decimal means and 8 octal.)
  • 9910 = 1438
  • 36310 = 5538
  • 521010 = 121328
  • 4756910 = 1347218