# The use of the Octal system

I was teaching the Octal number system and a student raised the question "Why should we use the octal number system, if we have binary and hexadecimal?" I was very confused, trying to explain the importance of this topic.

For context, I am teaching a course about the relationship between hardware and software.

• I suspect it is easier to teach octal before hexadecimal. Then explain that it is not used much these days, but is still used. May 25, 2017 at 19:27
• Could you please tell: what is the subject of the whole lesson? I'm trying to guess the amount of time devoted to the octal system and its place in the general context of the lesson. Because, per my opinion, learning explicitly octal for those who already have experience with binary and hexadecimal is really unneeded — octal is used relatively rare and a student having experience with other 2ⁿ-base systems would catch it on-the-fly when he meets it in real life. I'd rather ensure that they know two topics: generic conversion and m-base↔mⁿ-base conversion (especially for m=2). May 27, 2017 at 14:52
• It was important to know in the 1980s, when there were still computers for which the natural expression of the bit-ness was octal in common use. There are still Unix-isms where knowledge of octal is useful, otherwise I'd agree it's mostly a waste of time. Dec 3, 2017 at 3:48
• I teach my students octal and ask them, each year: Why do computer programmers confuse Halloween with Christmas? Answer: armchairdissident.wordpress.com/2009/04/15/… May 27, 2018 at 17:59
• Actually lots of current programming languages follow the brillant idea of octal numbers starting with 0. What could go wrong with int january = 01, february = 02, ...; Feb 9, 2019 at 10:50

The value might not be in knowing octal itself (although as noted in the comments, there is inherent relevance to it). Rather, it might be what learning different bases teaches about abstraction and the representations of numbers in general.

I think of this Essential Knowledge statement from the AP CS Principles curriculum:

EK 2.1.1G Numbers can be converted from any base to any other base.

The transition from decimal to binary is one step, and the move to hexadecimal can be an even bigger jump. To then have students see that there can be base-8 or base-32 or base-60 or base-37 is at times mind-blowing. The design of a particular base system, while not entirely arbitrary, is a design choice that comes with advantages and trade-offs.

Moreover, this process of conversion to and from different base systems strengthens students understanding of the underlying algorithmic process. The example I share with students is that 100 in any base system is equal to the value of that base squared. (Indeed it verges upon tautology.) Part of that is breaking down the idea of the 1s place being followed by the 10s followed by the 100s, etc. and replacing it with 10^0 followed by 10^1, etc. Replacing 10 with 2, 8, 16, or any other integer becomes trivial.

Having students see that 100 is not so much "one hundred" but a combination of base numbers and exponents and why that is is powerful.

• I always thought there was a case for Ternary in electronics. I just found out about a Soviet computer based on ternary. Long ago I created a simple program to convert a number to "balanced ternary" (-1, 0 and 1 are the 'digits') which would work great for mapping to electrical signals - negative, zero, positive. (Didn't RS-232 used to work that way?) Anyhow, awareness of different representation methods is very important. And base 64 is so interesting...
– user737
Jul 13, 2017 at 18:03

Sometimes you just want to group your bits 3 at a time instead of 4.

Octal groups 3 bits per digit. Hexadecimal groups 4 bits per digit.

For example Unix file permissions are written in octal because each group of 3 bits represents read, write and execute for either the user, group, or "other people". That is, the permissions 110110000 represent permissions rw-rw--- on the mask rwxrwxrwx where the group of 3 maps to (user, group, other). You can write it as 110110000, octal 660 or symbolically ug=rw. 6 always means read, write, but not execute no matter what position it is in. The position always means who is affected. However writing it in hexadecimal would be useless: 1B0 doesn't visually indicate to the reader what the permissions are.

In hardware systems grouping 3 bits at a time makes sense when many controllers each have 3 bits of value. An octal number like 0123 means send 001 to the first controller, 010 to the second controller, and 011 to the third controller.

Older computers were not 16-, 32-, or 64-bit but instead were often 9-bit or 36-bit. In that case, octal makes more sense because each group of 3 bits was a digit.

Reading older code often requires knowing octal because older code uses octal for many of the reasons listed above.

EDIT --- and even with recent code, you may encounter problems as

 january = 01;
february = 02;
...               // disaster waiting to happen


https://softwareengineering.stackexchange.com/questions/221797/reasoning-behind-the-syntax-of-octal-notation-in-java

• I agree, I thing it can also be useful to practice other number bases. Base 3 is interesting when you have digits of -, 0 and +. There are other number bases that they may already know: E.g ask when is $11 + 3 = 2$? Dec 2, 2017 at 18:06
• +1 on a working example... until you throw the setuid/setgid/sticky bits in :) Dec 5, 2017 at 5:06

It's necessary to know about octal because some compilers and tools will interpret multi-digit numbers with leading zeros differently to how many people will read them. Tracking down this sort of bug is very hard (as in spoken language where two people interpret words differently - maybe a useful analogue to work into a conversation).

I found two other relevant questions on SE: https://softwareengineering.stackexchange.com/questions/98692/where-are-octals-useful

https://stackoverflow.com/questions/2609426/in-what-situations-is-octal-base-used

The first identifies quite a lot of genuine legacy applications, which seem to be driven in the main by resource constraints which are not likely to be so relevant any more. The second question doesn't add anything more that I can see.

About the only time where Octal could be useful is in packing more separate items into a 32 bit register, and I'm struggling to decide if this is just obvious or actually a useful concept. It's closely related to ideas like video encoding, where RGB can be packed as 5,5,6 bits - but I'm not aware of this leading to the use of octal in the representations. Video is of course one of the areas today where resource constraints are very real (8.3 Mp per frame@60 Hz).

• The first case is more about teaching the idiosyncrasies of the tools involved. Dec 4, 2017 at 13:14

An octal representation is shorter, in characters, than a binary representation for data with any number of bits greater than one.

Unlike hexadecimal, an octal representation can be displayed using only numeric characters, of which certain old technologies (such as Nixie tubes and 7-segment LEDs) were capable (back, depending on the students age, perhaps in ancient history).

• I don't think this is a relevant answer here. It might fit in retrocomputing, but I get twitchy every time people use 1970's tech (or earlier) to justify a modern education topic. May 25, 2017 at 13:27
• 7 seg can do a-f May 25, 2017 at 19:26
• @SeanHoulihane How much has TCP/IP changed since the 1970s? Where would this site be if nobody understood such ancient technology? Sometime one cannot escape the current, real-world application of ancient technology. Were relevant it must still be a modern education topic. Jun 13, 2017 at 6:12
• @GypsySpellweaver - not quite sure I get your meaning, but I see legacy constructs holding back design all the time. Teaching legacy stuff as if it had meaning is a big mistake. Jun 13, 2017 at 7:28
• Those who don’t study history (including computer history) are condemned to repeating historical mistakes. Dec 29, 2017 at 16:28

3 bits per octal digit was convenient on old time machines which used words of 12, 18, 36 bits words. Easier to do mental calculations than with hexadecimal.

For example, you have the PDP family : PDP-1 & 4 are 18 bit machines, PDP-2 24 bits, PDP-3 and -6 36 bits, PDP-5 12 bits, etc.

PDP-11 was a 16 bit machine, but as far as I remember the documentation explained low level stuff with octal numbers.

At the time, characters were often coded on 6 bits (IBM 704 BCD, DEC SIXBIT, ...)

So the fundamental question is: why are you teaching numeration systems at all? Did you ever have to explain why

int month = 09;


is refused by the C compiler (and lots of modern languages), where as 07 and 10 are ok? And 012 is october?

You'll have to talk about octal numbers, even if you don't want to! :-)

• Cool: 012 is October (latin for 8th month). ☺ May 24, 2018 at 13:52

One lesson that hasn't been mentioned yet is that the basic (manual) algorithms that students use for addition, subtraction, etc. are independent of base. In Octal, you just "carry" when you get to "eight" rather than the "ten" they use with decimal numbers. This is a unifying concept that is useful to know.

Not that it is especially relevant, but it is said that if you have horse that can write and ask it to write out "ten" it will write "22". Similarly, if you ask it to stamp its foot 10 times, you hear "stamp, stamp, stamp, stamp".

While the above paragraph is intended as a joke, it provides a certain insight into number bases that might actually be helpful to students.

I also find it interesting that different European languages have names for the smaller numbers up to some limit, but the limit differs by language.

German, like English, has number names for 1 - 12, with 13 being a compound(-ish) name thir-teen (three and ten), or dreizehn. French, on the other hand has names for 1 - 16, with dix-sept (ten and seven) being 17. But the Latin-derived languages (Romance Languages) aren't consistent in this. Italian, for example, only has individual names for 1-10, with eleven being undici (one and ten) and Spanish has names for 1-15 with 16 being dieciséis (ten and six). German uses null for 0, and the Romance languages seem to use some form of zero, perhaps accented, zéro in French. I haven't done a comprehensive search, however.

It may be that the names of these numbers derive from commercial considerations, early marketplaces/marketdays, for example, and so depend more on local culture. This is a bit distinct from their use in mathematics, which tends to be more uniform.

And note that English is a compound language with both Germanic and French roots and we take 1-12 from German, but 0 from French.

• This answer doesn't explain why Octal is important, it only talks about other base systems in general. Therefore I don't see its relevance to the question. Feb 14, 2019 at 14:05
• @RolandIllig, yes, perhaps. I intend to provide a bit of background on the larger issue as a service to classroom teachers. Feb 14, 2019 at 14:11

One vestige of octal notation is in UNIX (includes macosx) file permissions. You can say ($is your system prompt) $ chmod 644 file.txt


and change all rings (user, group, and other) permissions in a quick and compact way. The first argument to chmod is a three-digit octal number. The first digit represents user permissions, the second group, and the third others. Read permission has value 4, write 2, and execute 1. The combinations work as follows

0  none
1  x
2  w
3  wx
4  r
5  rx
6  rw
7  rwx