octal number system

[bā jìn zhì]
Counting method based on 8
Collection
zero Useful+1
zero
Octal, short for OCT or O, an 8-based Counting method , use 8 numbers 0, 1, 2, 3, 4, 5, 6, 7, and enter 1 every eight. Some programming languages often start with the number 0 to indicate that the number is octal. Octal Numbers and binary numbers can correspond to each other bit by bit (one octal bit corresponds to three binary bits), so they are often used in computer Language.
Chinese name
octal number system
Foreign name
Octal
Cardinal number
eight
Interpretation
Every eight into one

Introduction to Counting

Announce
edit
Octal, Abbreviation OCT or O, an 8 based Counting method , use 8 numbers 0, 1, 2, 3, 4, 5, 6, 7, and enter 1 every eight. Some programming languages often start with the number 0 to indicate that the number is octal. Octal Numbers and binary numbers can correspond by bit (one octal bit corresponds to three binary bits), so they are often used in computer languages.
Octal (base 8) notation is very common in computer systems, so we sometimes see people using octal notation. Since one hexadecimal digit can correspond to four digits Binary digit , it is convenient to use hexadecimal to represent binary. Therefore, the application of octal is not as good as hexadecimal. somewhat Programming language It provides the ability to use octal symbols to represent numbers, and there are still some older Unix applications that use octal.
The computer needs number system conversion. The computer uses binary system internally. The number system conversion between binary octal and decimal systems is compiled by FORTRAN77. The number system conversion between binary octal and decimal systems is completed around binary and decimal systems. [1]

Counting history

Announce
edit
It has been suggested that the word "nine" in the original Indo European language family may be "new" with school. On this basis, it was speculated that the original Indo European language system used an octal number system.
In an article by John Wilkins in 1668, he proposed to a real system and philosophical language that 8 should be used as the cardinal number instead of 10, because the dichotomy is the most natural way to divide a number into two parts, so this number can be unified with the next number.
In 1716, Swedenborg, the Swedish king Charles XII, stated that the cardinal number was 64 instead of 10. However, Swedenborg thought that people with lower intelligence than the king were too difficult to understand, so he proposed 8 as the base. What are the numbers of 1 - 7 using the consonant l, year, n, m, t, f, u (v) and zero vowel o. Therefore, 8="lo", 16="so", 24="no", 64="loo", 512="looo" and other consecutive consonants and vowels are pronounced according to special rules. [5]
In July 1745, Hugh Jones proposed an octal system for British coins, weights and measures. The reason is that a unified standard is more convenient for all quantities; It is called the Georgian Standard; He divided every integer into eight equal parts, and each part was divided into eight real or imaginary examples. At that time, all countries generally used the base ten (the first two handed number), but 8 was a more complete and spacious number; Because it is divided by half, quarter, half quarter (or unit) has no score, so it is easy to subdivide Even in the later discussion "Jones (1753) of eight digit calculation thought that" octal arithmetic seems to be the most desirable thing, and at the same time it is closest to the essence of things, so it can be called the most natural number. Although it is opposed to using it now, decades later, it may be popular arithmetic. "
In 1801, James Anderson criticized the French metric system based on decimal operations. At his suggestion, octal was created. Suggest a pure octal Measuring System And the observed existing system of English units has largely evolved into an octal system.
In the mid-19th century, Alfred Taylor believed that "if we use eight radixes, we will surpass all counting methods" because it is the best arithmetic system ". "The proposal includes graphical symbols of new numbers and numbers of new names", including unty , duty , thety , foty , paty , sety , kity and under wait. For example, the number 65 decimal (101) is called under-un [2]

Application of counting method

Announce
edit
Octal is widely used in computer systems, such as PDP-8, ICL 1900 and IBM mainframe Use 12, 24, or 36 bits. Octal is the basis for these, because their ideal binary word abbreviation size can be divided by 3 (each octal digit represents three Binary digit )。 4、 Eight to twelve numbers can show the whole machine concisely. It also reduces costs so that numbers are allowed to be used in the operator console through nixie tubes, seven segment displays, and calculators. They are too complex for binary display. However, decimal display requires complex hardware, and hexadecimal display requires more numbers.
However, all modern computing platforms use 16 - 32 bits, or 64 bits. If 64 bits are used, they will be further divided into octets. In this system, three octal digits can meet the needs of each byte, and the most important octal digits represent two Binary digit (+1 is the next byte, if any). The octal representation of a 16 bit word requires 6 digits, but the most important octal digit represents (pass) only one (0 or 1). This means that it is not possible to provide an easy to read byte because it is a 4-digit octal digit.
Therefore, hexadecimal is a more common programming language today, because two hexadecimal digits completely specify one byte. For some platforms, the power of 2, word size and instructions are easier to understand. The modern ubiquitous x86 architecture also belongs to this category, but octal rarely uses this architecture. Although the binary encoding of some attribute operation codes becomes more obvious, when displayed in octal, such as ModRM byte, it is divided into 2, 3 and 3 bits, so octal can be used to describe these codes.
Octal is sometimes used for calculation rather than hexadecimal, perhaps most often in modern Unix systems with file permissions. Its advantage is that it does not require any additional sign digits (the hexadecimal system is radix 16, so six additional symbols beyond 0 - 9 are required). It is all used for digital display.
In programming languages, octal characters are usually combined with different prefixes, including the number 0, the letter o or q, the digit letter 0 o, or the symbol&[11] or the dollar. In Motorola convention, octal digits are prefixed with @, while the small letter o is added as a suffix in Intel Convention. DR-DOS debugging uses prefixes to edit octal digits.
For example, text 73 (octal) can be expressed as 073, o73, q73, 0o73, 73, @ 73,&73, $73 or 73o in various languages.
The new language has abandoned the prefix 0, and decimals are often represented by leading zeros. Avoid that the prefix o is mistaken for zero, and the prefix 0 starts with the introduction of o to avoid numeric literals in English letters (such as o or q), because these may cause literals to confuse variable names. The prefix 0 o also follows the prefix 0 x set by the model for hexadecimal character C language; It supports Haskell, OCaml, Perl 6, Python 3.0, Ruby, Tcl version 9, and its purpose is to support ECMAScript 6 (ECMAScript 3 and ECMAScript 5 with prefix 0 abandoned [21]).
Octal numbers are used in some programming languages (C, Perl, PostScript...) to represent byte strings in text/graphics. When some byte values (a code page represents non graphics, it has a special meaning in the current context. [3]

Counting conversion

Announce
edit
Binary and Octal The mutual conversion is similar to the conversion between binary and hexadecimal, but the difference is that you need to operate on a group of three bits rather than four bits. Table 2-2 lists the equivalent representations of binary and octal.
In order to Octal number Convert to binary, and replace each octal digit with the corresponding three digits in Table 2-2. For example, octal 123 is converted to Binary The result is 001010011:
one
two
three
001
010
011
Table 2-2 Binary/octal conversion table
Binary
octal number system
000
zero
001
one
010
two
011
three
one hundred
four
one hundred and one
five
one hundred and ten
six
one hundred and eleven
seven
To put a Binary number To convert to octal, just divide the binary string into groups of every three bits (if necessary, add zero in the front), and then look up Table 2-2 to replace the bit string of a group of three bits with the corresponding Octal number Words are enough.
If you need to convert octal numbers to hexadecimal numbers, just convert octal numbers to binary numbers, and then convert them to hexadecimal numbers.
Octal to decimal
Example: convert octal number 12 into Decimal number
Octal to binary
Rule: in order, every 1 bit Octal number Rewrite to 3 equivalent bits Binary number , the order remains unchanged.
For example: (17.36) 8=(001 111. 011 110) 2=(1111.01111) 2
Octal to hexadecimal
First convert octal to binary, and then convert binary to hexadecimal.
For example: (712) 8=(1110 0101 0) 2=(1CA) 16
Convert to octal
Binary to octal
integer Part from LSB At the beginning, each group is composed of 3 bits. If the most significant bit is less than 3 bits, it is supplemented with 0. Each group can be converted into one Octal Value. After conversion, it is an octal integer.
The decimal part starts from the most significant digit and is composed of three digits. If the least significant digit is less than three digits, it is supplemented with 0. Each group can be converted into an octal value. After conversion, it is an octal decimal.
For example: (11001111.01111) 2=(011 001 111.011 110) 2=(317.36) 8
Hexadecimal to octal
First, the hexadecimal system is converted to binary system with the method of 1 to 4; Then use the 3 and 1 method to convert the binary system into the 8 system.
For example: (1CA) 16=(111001010) 2=(712) 8
Note: The high-order zero before the decimal point and the low order zero after the decimal point can be removed.
Decimal octal
Method 1: Divide 8 and take remainder.
Example: Set Decimal number 115 into Octal number
8| 115…… 3
8| 14 …… 6
8| 1 …… 1
Result: (115) ten = (163) eight
Decimal Octal Example
Method 2: First decimal the binary number, then convert the binary number to octal number
Example: (115) ten = (1110011) two = (163) eight
Expression in C language
In C, integers have three forms of expression: decimal, octal, and hexadecimal. It starts with the number 0, and numbers from 0 to 7 are octal. The hexadecimal system starts with 0X or 0x and consists of 0~9, A~F or a~f. In addition to the positive and negative symbols, it starts with 1~9 and consists of 0~9 as the decimal system.
1. Decimal: in addition to positive and negative symbols, it starts with 1~9 and consists of 0~9. For example, 128,+234, - 278.
2, octal: a number starting with 0 and consisting of 0~7. For example, 0126, 050000
3. Hexadecimal: It starts with 0X or 0x and consists of 0~9, A~F or a~f. For example, 0x12A, 0x5a000.