I just banged my head against the table for some 20 minutes looking at a totally weird bug in PHP, and then I realized there's octal. The <%(*&#> octal.

In short, I padded some literals with zeros so the code would be aligned, I know, big mistake. Forgot about octals.

The question is, does anyone use octals for anything other than file permissions? (I personally prefer chmod ugo+rwx but I understand that if they have to be programmaticaly generated, it's useful to use octals.) But are they useful in any other situation?

  • 19
    Option A: Blame yourself. Option B: Blame the world. Option C: chuckle as you have learned something.
    – Job
    Aug 4, 2011 at 18:50
  • 13
    @Petrozza - IMO the C-style use of a leading zero to indicate octal was never a good choice, but it's history - probably a bit of C heritage, though it may be even older. I think Ada has one of the better conventions - an octal number would be written 8#1234567#, a hex number 16#abcdef#, etc and leading zeros are just leading zeros - any base from 2 to 16 (at least) is valid, and all are visually obvious and easy to understand.
    – user8709
    Aug 4, 2011 at 22:16
  • 2
    @Petruza Your question in its original form was not constructive for this site, and it was improved by the community so that it could remain open: please see the FAQ for more information about why people do this and why we encourage it. If you have any additional questions or concerns, please raise them on our meta-discussion site, not in your question.
    – user8
    Aug 6, 2011 at 7:50
  • 11
    Option D: "blame PHP" is always the right choice, regardless of the problem
    – Cephalopod
    Jan 19, 2014 at 7:49
  • 2
    @Steve314 I totally agree. Another noteworthy example is Python where they have the 0o prefix (which is consistent with 0x and 0b but perhaps a little hard to distinguish from 00). And since Python 3, extra leading zeros a re a syntax error to prevent this kind of bugs.
    – 5gon12eder
    Sep 15, 2015 at 4:34

11 Answers 11


According to Wikipedia, octals aren't as common as they used to be. As others have already mentioned, in the past, systems used to have a 12/24/36-bit word, which is more easily represented in octal than hexadecimal, but currently, the x86 and i64 architectures use a 16/32/64 bit word, which is more easily represented in hexadecimal and downright ugly in octal.

Current uses, however, include:

Note that modern programming languages sometimes don't support octals anymore because of the lack of use-cases and the potential for bugs. C# is an example, as Eric Lippert wrote this in the TCPL 3rd and 4th edition:

C# does not support octal literals, for two reasons. First, hardly anyone uses octal literals these days. Second, if C# supported octal in the standard "leading zero means octal" format, then it would be a potential source of errors. Consider this code:

    FlightNumber = 0541;

Clearly this expression is intended as a decimal literal not an octal literal.

Related, and just for reference and curiosity, Code, The Hidden Language of Computer Hardware has an excellent easy-to-follow explanation on octal and other number systems on page 55 - 63.

  • 1
    On that note, watch out for Javascript when handling user input. parseInt(011)==9
    – Darien
    Aug 5, 2011 at 0:01
  • 3
    That's really interesting about the Yuki and Pamean. It just occurred to me that hexadecimal finger counting is reasonably easy, if you use the inside of each finger, using some variation, like this
    – ocodo
    Aug 5, 2011 at 1:28
  • 3
    +1 for a very comprehensive answer. Grace Hopper once said she had troubles balancing her checkbook, because she had become so proficient at adding in octal.
    – Macneil
    Aug 5, 2011 at 3:47
  • 15
    @detly, if I know I need to count large numbers I'll use my 10 digits as bits and count to 1024 with just my fingers (just be careful who you show #4, #128 & #132 to).
    – zzzzBov
    Aug 5, 2011 at 13:32
  • 1
    @Darien For posterity, this isn't going to be an issue if you're parsing user input from strings: parseInt('011') still returns 11. parseInt(011) returns 9 trivially because the interpreter processes the octal 011 into the integer 9 first, then hands the integer to the parseInt() function, which just returns its input when handed an integer. Dec 13, 2019 at 15:15

Octal was widely used some 50 years ago by Digital Equipment Corp. (DEC) and other companies that had computers with a 12-bit word (e.g. the PDP-8) or other multiples of six, such as 18 and 36 (e.g. UNIVAC 1108). I used both the PDP-8 and UNIVAC 1108 in grad school. Characters in both machines typically used six bits, not 8.

PDP-8 instruction format

PDP-8 instruction format -- note the bits are numbered 0 -> 11. Bit 0 was the MSB (most significant bit).

When DEC came out with the 16-bit PDP-11, they continued to use octal in their documentation instead of hexadecimal as used by the other minicomputer manufacturers coming out with 16-bit machines at the time. This was probably because of the multiple 3-bit fields within the PDP-11 instruction formats like Register, Mode and Src/Dest which lent themselves to be decoded as an octal digit. (Thanks to John Strohm for pointing this out.)

Interestingly, when Motorola came out with their 68000 microprocessor, which was heavily influenced by the PDP-11 and had the same 3-bit Mode and Register fields in the instructions, they chose to use only hexadecimal in their documentation.

Because the PDP-11 used octal notation, the original permission codes for Unix, which first appeared on the PDP-11, also used octal. This legacy persists in Linux, where the chmod command still uses octal to specify each of the three bit 'rwx' fields.

Some more trivia -- CompuServe, which was a widely used dial-up online service in the 1980's and early 1990's (before being overshadowed by AOL), ran on DEC minicomputers, at least originally. All user ID's were numeric, and at some point I made the observation that they never included any 8's or 9's in them, thus they were in octal. My old CIS ID was 70205.

  • 1
    Your comment about PDP-11 documentation is incorrect. The PDP-11 had 8 registers. R0-R5 were general purpose registers. R6 was the stack pointer, and R7 was the PC. The MOV instruction took two 3-bit register numbers and two 3-bit addressing modes. Octal captures the register and mode fields PERFECTLY. (I strongly doubt that this was an accident.) Using hex would have confused everything. PUSH and POP were just addressing modes that used R6. Immediate operand was an addressing mode that used R7. Jan 18, 2014 at 5:53
  • @JohnR.Strohm Thanks for the comment re the 3-bit registers. I agree with your analysis and have updated my answer.
    – tcrosley
    Jan 19, 2014 at 5:23
  • So DEC worked in OCT. Should've just used multiples of 3.32 bits to avoid confusion.
    – user234461
    Aug 14, 2017 at 12:37
  • It’s funny how I never considered the Unix permissions to be an octal number, I always thought of it as three individual digits written together, each representing the three rwx bits, so they could be octal, decimal, or even hex.
    – axl
    Nov 17, 2017 at 5:33

Heathkit used them for the front panel of their H-8, and for assembly language listings of their front-panel software (called PAM-8). Dating myself, I know.

enter image description here

Nowadays octals are very rare; everyone seems to use hex. But numbers still look like numbers in octal, and you don't need an additional row of keys for the digits A through F.

  • 2
    +1 for the H-8. Despite being octal on the outside, the CPU was an 8080A, which was all bytes. Go figger.
    – Blrfl
    Aug 4, 2011 at 19:42
  • I'd guess they used octal for commonality with the H-11 (which had a PDP-11 CPU). Aug 4, 2011 at 23:03
  • 2
    The 8080 had 8-bit bytes, but the instruction set made more sense if looked at in octal than in hex.
    – RBerteig
    Aug 5, 2011 at 2:28

One of the reasons why octal sees use is because it's the largest base that is a power of 2 for which you don't need any special characters -- that is, all digits can be numeric. Base 16 (the next one up from base 8) requires non-numeric digits (usually A,B,C,D,E,F).

  • I know this is old, but why would using only numeric digits be preferable to also using letters?
    – Petruza
    Apr 2, 2019 at 12:50
  • 2
    E.g. one can tell instantly that 376 is larger than 375. With hex, one might need a second or two (depending on tiredness) to process whether FE is greater than FD
    – Magnus
    Jan 2, 2020 at 4:23
  • 1
    It's useful because everyone knows that digits are numbers. "FADE" may be a verb, or an abbreviation or code-name, or it could be 64222. But 0755 is definitely a number. You may guess the wrong base, but you have no confusion about what box it goes in; you can be dead-certain it's a number. Aircraft all over the world still today use octal (4-digit / 12-bit) transponder codes for interacting with ATC because it's less error-prone than trying to do the same thing in hex.
    – tylerl
    Jan 2, 2020 at 6:48
  • Numeric digits also have the advantage of being case-insensitive, so if you encode file names in octal (typically after hashing the original file name) then you can reference the file without issue on both case-sensitive and case-insensitive file systems.
    – Eric Mutta
    Apr 21, 2023 at 11:18

I use octal every day. Every time I need to chmod a file I use octal (I pre-date the u+r notation...). Every time I want to embed a control character inside a string I use octal... (Yes, I could use hex, but octal is what I use).

  • 2
    +1 for "but octal is what I use" :)
    – JoelFan
    Aug 4, 2011 at 23:28

Anybody who needs to express combinations of bits grouped in threes.

Why does anyone use hex?

Things off the top of my head that are expressed as octal numbers:

  • Codes squawked by Mode 3A transponders in airplanes
  • Certain values found on the ARINC 429 avionics bus
  • SCSI addresses
  • Key codes in the ncurses library
  • 12
    The difference is, hex is "natural" as half a byte. Two hex digits = 1 byte. But you can't divide bytes up into octal digits. Aug 4, 2011 at 18:51
  • 2
    The first line states the obvious. The second one makes a poor analogy.
    – back2dos
    Aug 4, 2011 at 19:07
  • 3
    And hex is completely unnatural for anything that needs to be expressed in groups of three bits like the aforementioned Unix file modes. There's no law that says a particular numbering system's digits have to line up with bytes. If there was, expressing anything to a computer as base 10 would be worse practice than base 8, which at least aligns itself with groups of bits.
    – Blrfl
    Aug 4, 2011 at 19:25
  • 6
    a typical hex string is obviously a hex string. octal isn't. Aug 4, 2011 at 20:00
  • 1
    @Blrfl: So how many of these mentioned "[things that] need to be expressed in groups of three bits" are there apart from the canonical example? That's the actual question, which you left unanswered thus far. Instead you make yet another poor analogy. There is actual use for decimal representation, because we simply learned to handle it. Which one will you calculate faster? 7 * 6 or 07 * 06? We use decimal to represent numbers as we can handle them best and hex to represent numbers very close to how the machine stores them. And we do this a lot. This site is full with evidence of it.
    – back2dos
    Aug 4, 2011 at 20:04

Back when I worked on CDC mainframes (with a 60-bit word, 12-bit word for the PPU), all the core dumps and such were done in octal (20 octal digits per word, 4 per PPU word).


Like hexadecimal, octal notation is sometimes used to specify character codes. It can be handy for the same reason that hexadecimal is: it's more compact than binary, but very easy to translate to binary in your head.


Nope. Never used them. Not even for setting file permissions, because I do it so rarely I find it hard to read.

So yes, there is the obvious benefit of conversion from and to binary.
However, as already pointed out by @Mason, hex is far more "natural", because 2 hex digits make one byte. Comes in handy to represent 24/32 bit RGB/ARGB colors, IP addresses, byte masks etc. Octal on the other side is not really practical, because you rarely have scenarios where you work in terms of 3-bit groups.

File permissions are in fact the only thing I could think about. And if there's no area of use as of now, I doubt there will ever be one. Since the last 20 years space has become so cheap, it has become very uncommon to pack information so tightly, at the cost of alignment, ease of use and extensibility.


Like Hex, Octal numbers are easy to convert from binary. Just group the binary digits in groups of three, starting at the right.

10010101110  // binary

// conversion
// so, in octal we have...

10010101110 (base 2) == 2256 (base 8)
  • 7
    This is obvious. The question is about when this is actually used.
    – back2dos
    Aug 4, 2011 at 19:09
  • 2
    @back2dos: then please feel free to post an answer instead of leaving the same comment multiple times. Aug 4, 2011 at 19:12
  • 5
    @Ed S. You didn't even try to answer the question. You said something obvious that the original poster almost certainly already knew the answer to. As the moderators are fond of saying, this isn't what we are shooting for. See meta.programmers.stackexchange.com/questions/1968/… for more.
    – btilly
    Aug 5, 2011 at 0:33
  • @back2dos, btilly - Answers on Stackexhange sites aren't just for the OP, they become a persistent resource for any passing reader. All obvious facts, aren't necessarily obvious to everyone, if this answer helps the penny-drop for someone it has value.
    – ocodo
    Aug 5, 2011 at 0:49
  • 2
    @Slomojo though by that argument, every question is eligible to become a wiki for every related aspect of a topic. The point is that this doesn't answer the question. This answer can certainly be valid somewhere else, to "How to quickly mentally convert to octal?"
    – Nicole
    Aug 5, 2011 at 0:52

A bit of an aside, but a public use is on the London Underground. Each train has both a physical identity, and a separate identity in the schedules which is displayed when in service - see here: https://upload.wikimedia.org/wikipedia/commons/4/49/LUL-S-Stock-at-Watford.jpg (note the 402 at the top of the destination display). Although the electronics for the displays are bog standard decimal-based, you never see digits 8 or 9 because they are tied to legacy octal-based hardware in the signalling system.

Not the answer you're looking for? Browse other questions tagged or ask your own question.