13
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ I suspect it is easier to teach octal before hexadecimal. Then explain that it is not used much these days, but is still used. $\endgroup$ May 25, 2017 at 19:27
  • 2
    $\begingroup$ 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). $\endgroup$
    – Sasha
    May 27, 2017 at 14:52
  • $\begingroup$ 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. $\endgroup$
    – pojo-guy
    Dec 3, 2017 at 3:48
  • $\begingroup$ 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/… $\endgroup$ May 27, 2018 at 17:59
  • $\begingroup$ 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, ...; $\endgroup$ Feb 9, 2019 at 10:50

8 Answers 8

11
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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... $\endgroup$
    – user737
    Jul 13, 2017 at 18:03
8
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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$? $\endgroup$ Dec 2, 2017 at 18:06
  • $\begingroup$ +1 on a working example... until you throw the setuid/setgid/sticky bits in :) $\endgroup$
    – ivanivan
    Dec 5, 2017 at 5:06
4
$\begingroup$

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).

$\endgroup$
1
  • $\begingroup$ The first case is more about teaching the idiosyncrasies of the tools involved. $\endgroup$
    – Bob Brown
    Dec 4, 2017 at 13:14
3
$\begingroup$

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).

$\endgroup$
5
  • 3
    $\begingroup$ 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. $\endgroup$ May 25, 2017 at 13:27
  • 3
    $\begingroup$ 7 seg can do a-f $\endgroup$ May 25, 2017 at 19:26
  • 2
    $\begingroup$ @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. $\endgroup$ Jun 13, 2017 at 6:12
  • 3
    $\begingroup$ @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. $\endgroup$ Jun 13, 2017 at 7:28
  • $\begingroup$ Those who don’t study history (including computer history) are condemned to repeating historical mistakes. $\endgroup$
    – hotpaw2
    Dec 29, 2017 at 16:28
1
$\begingroup$

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, ...)

See https://en.wikipedia.org/wiki/Six-bit_character_code

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! :-)

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

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.

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$ Feb 14, 2019 at 14:05
  • $\begingroup$ @RolandIllig, yes, perhaps. I intend to provide a bit of background on the larger issue as a service to classroom teachers. $\endgroup$
    – Buffy
    Feb 14, 2019 at 14:11
1
$\begingroup$

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

So, in the example above, the user has read/write permission, groups read, and others read.

$\endgroup$
0
$\begingroup$

As a step toward learning binary or hexadecimal. Show that we use many number bases everyday: base 24 and 60 in a clock; base 7 and base 30ish in a calender; base 16 and 14 in weights (in US); base 12 and 3 in distance (US); etc.

Then introduce octal. Octal has an advantage that it is not too different to Denary (Decimal), and that it dose not introduce new symbols (like hexadecimal).

After octal, head toward binary, maybe brefly explore the idea of other bases, and ask how low can we go? Binary is the limit.

Then binary to octal, but look at how this does not fit will in to 8 bit bytes. What can we do about this. Base 4 or base 16. Base 4 does not help us much, but is used by DNA. Base 16 helps us reduce number of digits, but we need 6 more symbols (a-f).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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