# Octal system

The octal system (from Latin octo ' eight ') is a place value system with the base 8 (hence also called the figure of eight ). It knows eight digits to represent a number: 0 , 1 , 2 , 3 , 4 , 5 , 6 and 7 .

Its origins can be found in Sweden of the 17th century ; as the author come King Karl XII. , the scientist Emanuel Swedenborg or the inventor Christopher Polhem in question.

 octal 0 1 2 3 4th 5 6th 7th 10 11 12 13 14th 15th 16 17th 20th decimal 0 1 2 3 4th 5 6th 7th 8th 9 10 11 12 13 14th 15th 16 binary (dual) 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10,000 hexadecimal 0 1 2 3 4th 5 6th 7th 8th 9 A. B. C. D. E. F. 10

## Counting in the octal system

When counting in the octal system, note that after 7 there is no 8, but must be increased one place further to the left. In the octal system: 7 + 1 = 10 . The application of this rule is illustrated below:

 0 1 2 3 4th 5 6th 7th 10 11 12 13 14th 15th 16 17th 20th 21st 22nd 23 24 25th 26th 27 ... ... ... ... ... ... ... ... 70 71 72 73 74 75 76 77 100 ... ... ... ... ... ... 107 110 ... ... ... ... ... ... 117 ... ... ... ... ... ... ... ... 770 ... ... ... ... ... ... 777

## Applications

### Computer technology

Each digit of an octal number can be represented by three bits . Conversely, an octal number can easily be generated from a binary number by grouping three bits each. For example, to represent the octal number 16 in the binary system, only the individual octal digits 1 and 6 have to be converted into binary numbers:

 octal binary 1 6th 0 0 1 1 1 0

Octal numbers are still used today to represent file access rights under Unix , where three bits each represent the rights of a user class (see chmod ). When data words with a length of 24 bits were still in use, the value range of which corresponded exactly to that of an eight-digit octal number, octal numbers were used for input and output of bit patterns, as they are clearer for humans than binary numbers and because the conversion from and to the binary system is easy. The hexadecimal system for input and output is more suitable for the data word lengths 16, 32 and 64 that are now common . Characters (8 bits) are represented in octal relatively often.

### aviation

The transponder code (squawk) in every aircraft works with octal numbers.

## Labelling

Octal numbers are often identified by a trailing o (also known as the Intel Convention). In the programming languages C , Java and Python (versions up to 2.x) a 0 (zero) is prefixed to differentiate an octal number from a decimal number (which can lead to careless errors that are difficult to detect: 0715 is not equal to 715). In Python 3, the number 0 and the lowercase letter o (e.g. 0o715) are prefixed for better distinction. In TeX , an octal number is indicated by a preceding apostrophe. According to the Motorola Convention, however, octal numbers are marked with a preceding @ sign (e.g. @ 715). Under DR-DOS , DEBUG supports octal numbers in conjunction with the prefix \ (e.g. \ 715). This representation comes from the Unix world, where it is supported by common shells. The C programming language also uses them to represent characters.

In mathematics , the base of the number system is often added to the number, e.g. B. 172 (8) = 122 (10) .

Example: 172o = 172 (8) (math) = 0172 (in C or Java) = '\ 172' (in C) = '172 (TeX).

## Conversion of decimal numbers into octal numbers

A (natural) decimal number can be converted into an octal number by repeatedly dividing it by the base 8 and noting the remainder of the division . For example, the decimal number 122 (10) requires three calculation steps:

122 : 8 = 15 Rest 2
 15 : 8 =  1 Rest 7
  1 : 8 =  0 Rest 1

The remainder of the division read from bottom to top gives the octal number 172 (8) .

## Conversion of octal numbers to decimal numbers

To convert a (natural) octal number into a decimal number, you have to multiply the individual digits by the respective power of the base. The exponent of the base corresponds to the digit, with the rightmost digit assigned to zero. Example for 172 (8) (where the calculation is notated in the decimal system):

${\ displaystyle [172] _ {8} = 1 \ cdot 8 ^ {2} +7 \ cdot 8 ^ {1} +2 \ cdot 8 ^ {0} = 122_ {10}}$

The number of multiplications can be reduced by using the Horner scheme :

${\ displaystyle [172] _ {8} = (1 \ cdot 8 + 7) \ cdot 8 + 2 = 122_ {10}}$

This table represents the same as the above terms; you take the column name (e.g.) "8 1 = 8" with the value given in the cell times; if there is a 3 in row 1, column "8 1 = 8", then "8 1 × 3" is calculated

decimal number 8 4 = 4096 8 3 = 512 8 2 = 64 8 1 = 8 8 0 = 1 Final octal number
5 0 0 0 0 5 5
16 0 0 0 2 0 20th
86 0 0 1 2 6th 126
123 0 0 1 7th 3 173

## Representation of rational and real numbers

As with all place value systems, any rational or real numbers can be represented in the octal system. In German-speaking countries, the comma is usually used as the separator between the integer and fractional part of the number. The values ​​of the digits after the separator are multiplied by, whereby the position after the comma indicates. ${\ displaystyle 8 ^ {- i}}$${\ displaystyle i}$

Example of converting 34.56 (8) to the decimal system (where the notation for the calculation is in the decimal system):

${\ displaystyle 3 \ cdot 8 ^ {1} +4 \ cdot 8 ^ {0} +5 \ cdot 8 ^ {- 1} +6 \ cdot 8 ^ {- 2} = 28 {,} 71875 _ {(10) }}$

In the opposite direction, the fractional part of a decimal number is converted into octal representation by continual multiplication by 8, with the integer part of the result providing an octal digit. For example, the decimal number 0.3984375 (10) requires three calculation steps:

8 · 0,3984375 = 3,1875
8 · 0,1875    = 1,5
8 · 0,5       = 4,0

The octal number we are looking for is therefore 0.314 (8) .

Of course, it can happen that this process does not break off and that the result is an infinite octal fraction. A periodic representation is also possible, as the following example of the conversion of 0.2 (10) shows:

8 · 0,2 = 1,6
8 · 0,6 = 4,8
8 · 0,8 = 6,4
8 · 0,4 = 3,2
8 · 0,2 = ...

Now the lines repeat themselves, and the octal number we are looking for is therefore . ${\ displaystyle 0 {,} 14631463 \ ldots _ {(8)} = 0 {,} {\ overline {1463}} _ {(8)}}$

Every rational number has a finite or an infinite periodic octal fraction expansion. Is , where is an integer and a natural number, and this fraction is shortened (i.e. and relatively prime ), then has a finite fraction expansion if and only if is a power of two . ${\ displaystyle r}$${\ displaystyle r = {\ frac {p} {q}}}$${\ displaystyle p}$${\ displaystyle q}$${\ displaystyle p}$${\ displaystyle q}$ ${\ displaystyle r}$${\ displaystyle q}$

As is usual with place value systems, the representation of rational numbers is not always clear; z. B. In addition to representation 1 , the one also has the following as a periodic octal fraction:

${\ displaystyle 1 = 0 {,} 777 \ ldots _ {(8)} = 0 {,} {\ overline {7}} _ {(8)}}$.

## Trivia

The alien Na'vi from the movie Avatar: Departure for Pandora use the octal system because they have four fingers on each hand.

In the TV series Stargate , the ancients also used the octal system.