Octal


Octal is a numeral system for representing a numeric value as base 8. Generally, an octal digit is represented as "0" to "7" with the same value as for decimal but with each place a power of 8. For example:
In decimal, each place is a power of ten. For example:
An octal digit can represent the value of a 3-digit binary number. For example, the binary representation for decimal 74 is 1001010. Two zeroes can be added at the left:, corresponding to the octal digits, yielding the octal representation 112.

Multiplication table

×123456710
1123456710
22461012141620
336111417222530
4410142024303440
5512172431364350
6614223036445260
7716253443526170
1010203040506070100

Usage

In China

The eight bagua or trigrams of the I Ching correspond to octal digits:
  • 0 = ☷, 1 = ☳, 2 = ☵, 3 = ☱,
  • 4 = ☶, 5 = ☲, 6 = ☴, 7 = ☰.
Gottfried Wilhelm Leibniz made the connection between trigrams, hexagrams and binary numbers in 1703.

By Native Americans

  • The Yuki language in California has an octal system because the speakers count using the spaces between their fingers rather than the fingers themselves.
  • The Pamean languages in Mexico also have an octal system, because some of their speakers "count the knuckles of the closed fist for each hand, so that two hands equals eight."

    By Europeans

  • It has been suggested that the reconstructed Proto-Indo-European word for "nine" might be related to the PIE word for "new". Based on this, some have speculated that proto-Indo-Europeans used an octal number system, though the evidence supporting this is slim.
  • In 1668, John Wilkins in An Essay towards a Real Character, and a Philosophical Language proposed use of base 8 instead of 10 "because the way of Dichotomy or Bipartition being the most natural and easie kind of Division, that Number is capable of this down to an Unite".
  • In 1716, King Charles XII of Sweden asked Emanuel Swedenborg to elaborate a number system based on 64 instead of 10. Swedenborg argued, however, that for people with less intelligence than the king such a big base would be too difficult and instead proposed 8 as the base. In 1718 Swedenborg wrote a manuscript: "En ny rekenkonst som om vexlas wid Thalet 8 i stelle then wanliga wid Thalet 10". The numbers 1–7 are there denoted by the consonants l, s, n, m, t, f, u and zero by the vowel o. Thus 8 = "lo", 16 = "so", 24 = "no", 64 = "loo", 512 = "looo" etc. Numbers with consecutive consonants are pronounced with vowel sounds between in accordance with a special rule.
  • Writing under the pseudonym "Hirossa Ap-Iccim" in The Gentleman's Magazine, July 1745, Hugh Jones proposed an octal system for British coins, weights and measures. "Whereas reason and convenience indicate to us an uniform standard for all quantities; which I shall call the Georgian standard; and that is only to divide every integer in each species into eight equal parts, and every part again into 8 real or imaginary particles, as far as is necessary. For tho' all nations count universally by tens yet 8 is a far more complete and commodious number; since it is divisible into halves, quarters, and half quarters without a fraction, of which subdivision ten is uncapable...." In a later treatise on Octave computation Jones concluded: "Arithmetic by Octaves seems most agreeable to the Nature of Things, and therefore may be called Natural Arithmetic in Opposition to that now in Use, by Decades; which may be esteemed Artificial Arithmetic."
  • In 1801, James Anderson criticized the French for basing the metric system on decimal arithmetic. He suggested base 8, for which he coined the term octal. His work was intended as recreational mathematics, but he suggested a purely octal system of weights and measures and observed that the existing system of English units was already, to a remarkable extent, an octal system.
  • In the mid-19th century, Alfred B. Taylor concluded that "Our octonary radix is, therefore, beyond all comparison the "best possible one" for an arithmetical system." The proposal included a graphical notation for the digits and new names for the numbers, suggesting that we should count "un, du, the, fo, pa, se, ki, unty, unty-un, unty-du" and so on, with successive multiples of eight named "unty, duty, thety, foty, paty, sety, kity and under." So, for example, the number 65 would be spoken in octonary as under-un. Taylor also republished some of Swedenborg's work on octal as an appendix to the above-cited publications.

    In computers

Octal became widely used in computing when systems such as the UNIVAC 1050, PDP-8, ICL 1900 and IBM mainframes employed 6-bit, 12-bit, 24-bit or 36-bit words. Octal was an ideal abbreviation of binary for these machines because their word size is divisible by three. So two, four, eight or twelve digits could concisely display an entire machine word. It also cut costs by allowing Nixie tubes, seven-segment displays, and calculators to be used for the operator consoles, where binary displays were too complex to use, decimal displays needed complex hardware to convert radices, and hexadecimal displays needed to display more numerals.
All modern computing platforms, however, use 16-, 32-, or 64-bit words, further divided into eight-bit bytes. On such systems three octal digits per byte would be required, with the most significant octal digit representing two binary digits. Octal representation of a 16-bit word requires 6 digits, but the most significant octal digit represents only one bit. This representation offers no way to easily read the most significant byte, because it is smeared over four octal digits. Therefore, hexadecimal is more commonly used in programming languages today, since two hexadecimal digits exactly specify one byte. Some platforms with a power-of-two word size still have instruction subwords that are more easily understood if displayed in octal; this includes the PDP-11 and Motorola 68000 family. The modern-day ubiquitous x86 architecture belongs to this category as well, but octal is rarely used on this platform, although certain properties of the binary encoding of opcodes become more readily apparent when displayed in octal, e.g. the ModRM byte, which is divided into fields of 2, 3, and 3 bits, so octal can be useful in describing these encodings. Before the availability of assemblers, some programmers would handcode programs in octal; for instance, Dick Whipple and John Arnold wrote Tiny BASIC Extended directly in machine code, using octal.
Octal is sometimes used in computing instead of hexadecimal, perhaps most often in modern times in conjunction with file permissions under Unix systems. It has the advantage of not requiring any extra symbols as digits.
In programming languages, octal literals are typically identified with a variety of prefixes, including the digit 0, the letters o or q, the digit–letter combination 0o, or the symbol & or $. In Motorola convention, octal numbers are prefixed with @, whereas a small letter o or q is added as a postfix following the Intel convention. In Concurrent DOS, Multiuser DOS and REAL/32 as well as in DOS Plus and DR-DOS various environment variables like $CLS, $ON, $OFF, $HEADER or $FOOTER support an \nnn octal number notation, and DR-DOS DEBUG utilizes \ to prefix octal numbers as well.
For example, the literal 73 might be represented as 073, o73, q73, 0o73, \73, @73, &73, $73 or 73o in various languages.
Newer languages have been abandoning the prefix 0, as decimal numbers are often represented with leading zeroes. The prefix q was introduced to avoid the prefix o being mistaken for a zero, while the prefix 0o was introduced to avoid starting a numerical literal with an alphabetic character, since these might cause the literal to be confused with a variable name. The prefix 0o also follows the model set by the prefix 0x used for hexadecimal literals in the C language; it is supported by Haskell, OCaml, Python as of version 3.0, Raku, Ruby, Tcl as of version 9, PHP as of version 8.1, Rust and ECMAScript as of ECMAScript 6.
Octal numbers that are used in some programming languages for textual/graphical representations of byte strings when some byte values have to be to escaped as \nnn. Octal representation may be particularly handy with non-ASCII bytes of UTF-8, which encodes groups of 6 bits, and where any start byte has octal value \3nn and any continuation byte has octal value \2nn.
Octal was also used for floating point in the Ferranti Atlas, Burroughs B5500, Burroughs B5700, Burroughs B6700 and Burroughs B7700 computers.