In what situations is octal base used?

和自甴很熟 提交于 2019-11-26 17:48:08

问题


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?


回答1:


Octal is used as a shorthand for representing file permissions on UNIX systems. For example, file mode rwxr-xr-x would be 0755.




回答2:


Octal is used when the number of bits in one word is a multiple of 3. Examples are ancient systems with 18bit word sizes, systems with 9bit bytes, or unix file permissions with 9bits or 12bits.

If the number of bits in your word is a multiple of 4, however, please do use hex, by all means.




回答3:


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.




回答4:


Didn't think of this but Digital displays!

Several other uses from: http://en.wikipedia.org/wiki/Octal




回答5:


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




回答6:


In avionics, ARINC 429 word labels are almost always expressed in octal.




回答7:


If birds could count, my guess would be that they use octal. While most birds have 3 digits on their feathered "hands", most are Tetradactyly, meaning 4 toes on each foot.




回答8:


Music, as long as you stay away from (most) sharps and flats.




回答9:


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



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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!