Octal is useless today. It is easy to convert between octal and binary, so octal was used in some early computers. But hexadecimal has totally replaced it in modern use. There’s no advantage that octal has over hexadecimal, which is why hexadecimal has replaced it.
The C programming language has support for values in octal. This wouldn’t be a problem, except for the horrible syntax used to define octal values.
In C, any integral value that starts with 0 is interpreted as octal! So 010
is eight, not ten. I’ve been bitten by this before. I don’t know why this syntax was chosen over an 0o
prefix (which google calculator uses), that would match the 0x
prefix for defining hexadecimal values. In retrospect it was almost certainly a mistake to go with the current syntax.
Anyway, the reason I’m writing this is because for the first time ever, I used an octal value in a C program. I had to create a directory structure that could be be accessed by different accounts on the same system. So I had to explicitly set it’s permissions when I created it with createDirectoryAtPath:attributes: . I wanted the NSFilePosixPermissions
value that determines the folders permissions to have the same format that the chmod command takes. And it takes an octal value. So 0777
is the first, and only, octal constant that I’ve written in any program. Even when I’ve written in assembly I’ve used hexadecimal. There’s a good chance I will never write another octal value — I hope that’s the case.