I've seen binary and hex used quite often but never octal. Yet octal has it's own convention for being used in some languages (ie, a leading 0 indicating octal base). When is octal used? What are some typical situations when one would use octal or octal would be easier to reason about? Or is it merely a matter of taste?
Octal is used when the syntax is a relic from the ages when it perhaps made sense on some platform (system words haven't always been a multiple of 8 bits). Nowadays hex is the thing to use.
Didn't think of this but Digital displays!
Several other uses from: http://en.wikipedia.org/wiki/Octal
Octal is used as a shorthand for representing file permissions on UNIX systems. For example, file mode rwxr-xr-x
would be 0755
.
Octal is used when your word consists of a number of bits divisible by 3: Ancient systems with 18bit word sizes, unix file permissions.
If the number of bits in your word is divisible by 4, however, please do use hex, by all means.
Octal is an invention by super-villains everywhere in an attempt to confuse programmers and obfuscate code. I believe the first originator of the concept was doc oct(al) in his fight with spiderman in Amazing Spider-Man #3 (July 1963).
Either that or just so that someone could have the following joke in their signature line:
why do programmers confuse christmas with halloween?
because dec25 == oct31
One of the main reasons octal used to be more frequently used was that it is easier to convert between octal and binary in your head than hex to binary: you only have to remember the binary representation of the 8 octal digits (0-7).
Back in the days when debugging meant reading register contents from a row of LEDs, or entering data with an array of toggle switches, this was a big concern. The panels on many of these early computers grouped the LEDs and switches in groups of threes to facilitate this.
However, hex began to win out as word sizes that are multiples of 8-bit bytes began to win out, and the need to read and enter data in binary became unecessary (with console text UI and later GUI debuggers).
FYI, there are a few places that windows and javascript automatically decide that a number prefixed with a zero is octal and convert the number.
In windows if you ping and address like 10.0.2.010 it will actually ping 10.0.2.8
Windows also does this if you enter it as the ip/dns address for the computer
Though it is deprecated, Javascript does this by default on some functions like parseInt if you do not specify a radix http://www.w3schools.com/jsref/jsref_parseint.asp
In avionics, ARINC 429 word labels are almost always expressed in octal.