# Understanding Octal

Why would we need to understand Octal?

The most relevant reason I can come up with right now is that looking back at some of the interview question challenges I’ve posted, there is one that deals with an Octal number. That question does not ask you to actually convert the number, but there is a variation of that problem which does. The last thing you want is to have to tell your interviewer that although you recognize that it’s an Octal number, and you know what the answer is *not* going to be, you don’t know what it *will* be.  This might pass in some interviews, particularly if they’re only trying to assess that you know it’s an Octal number. But if that’s the case, I would expect them to be using the example that does not require you to actually convert the number.

So, here’s the problem:

```\$i = 020;
echo \$i / 2;```

If you don’t know that you’re looking at an Octal number, you’ll answer 10. But let’s take a look at how Octal works so we can actually answer the problem and not just recognize that it’s an Octal number.

Here is the way you would go about solving this:

20 (octal)

(2 x 8^1)  + (2 x 8^0)

From right to left, multiply the digit times 8 to the power of the place. The right-most digit is the zero place, the next one is the first power, then second, etc…

(2 x 8) + (2 x 1)

16 + 2

18

So, 20 in octal is 18 decimal.

Here is one with three digits:

475 (octal)

(4 x 8^2) + (7 x 8^1) + (5 x 8^0)

(4 x 64) + (7 x 8) + (5 x 1)

256 + 56 + 5

317

I realize that my way of explaining it is likely to be unclear to some. The best recommendation I can offer if you are struggling with it is to visit the Wikipedia page. That’s where I started. Then just work through some problems on paper till it sinks in.