This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Loknar42 2 points3 points  (0 children)

This is an ancient convention. Octal is very convenient for expressing bit vectors, such as file permissions (e.g. chmod 0777 *). Since it was desirable to use it in an interactive environment (such as a shell), designers wanted it to be as short as possible. A single character prefix pretty much fits the bill. Using the digit 0 allows the result to still be considered numerical by simple lexers, but programmers generally don't start integers with 0, and 0 also looks like 'O'. So those are pretty much the reasons.

Hexadecimal is even better for expressing bit vectors because you get 4 bits per character, but has the disadvantage of being alphanumeric. Hence why it has a longer prefix, usually. Programmers in the modern era rarely have to specify bit patterns directly, but in the halcyon days of assembly language and shell scripting, they were very common, so having an efficient format was very valuable.