What Is an Octree?
Octal, Octal, abbreviation OCT or O, a counting method based on 8, using eight digits of 0,1,2,3,4,5,6,7, 1 every eight. Some programming languages often begin with the number 0 to indicate that the number is octal. Octal numbers and binary numbers can be mapped in bits (one octal corresponds to three binary digits), so they are often used in computer languages.
Octal, abbreviation OCT or O, a kind of base 8
It has been suggested that the word "nine" in the original Indo-European family might be "new" with the faction. Based on this, some people speculate that the original Indo-European language used an octal number system.
An article by John Wilkins in 1668 proposed to a real systemic and philosophical language to use 8 as the base, not 10, because dichotomy is the most natural way to divide a number into two parts. The number can be unified with the next value.
In 1716 Swedish King Charles Twelve ordered Swedenborg to state that the base 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 1-7 with consonants l, s, n, m, t, f, u (v) and zero vowel o. Therefore, 8 = "lo", 16 = "so", 24 = "no", 64 = "loo", 512 = "looo", etc. There are special rules for consonant and vowel sounds. [5]
In July 1745, Hugh Jones proposed an octal system for British coins. The reason is to tell us that a unified standard is more convenient for all quantities; it is called the Georgia standard; he divided each integer into eight equal parts, and each part was divided into 8 real or hypothetical examples. At that time, all countries generally used the base dozens (the number of the initial two hands), however, 8 was a more complete and spacious number; because it was divisible by half, quarter, half quarter (or unit) had no score, it was easy to subdivide ... Even later on, "Jones (1753) of eight-digit calculations argued 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 now opposed to using it, Decades later; this may be popular arithmetic. "
In 1801, James Anderson criticized the French metric system based on decimal arithmetic. He created octals on his advice. It is suggested that a pure octal weights and measures system and the existing system English units observed have largely evolved into an octal system.
In the mid-19th century, Alfred Taylor argued that "if we use eight bases, we will surpass all counting methods" because it is one of the best arithmetic systems. "" The proposal includes new graphical symbols and new numbers "The number of names" includes unty , duty , thety , foty , paty , sety , kity and under, etc. For example, the number 65 decimal (101) in octal is called under-un . [2]
Octal is widely used in computer systems such as PDP-8, ICL 1900, and IBM mainframes using 12, 24, or 36 bits. Octal is the basis because their optimal binary word abbreviation size is divisible by three (each octal digit represents three binary digits). Four, eight to twelve numbers can show the entire machine concisely. It also reduces costs by allowing numbers to pass through the nixie tube, seven-segment display, and calculator for the operator console. They are too complex to use in binary displays. However, decimal displays require complex hardware, and hexadecimal displays require more. digital.
However, all modern computing platforms use 16-32-bit, or 64-bit, and if 64-bit is used, it will be further divided into octets. In this system, three octal digits can meet the needs of each byte, and the most important octal digit represents two binary digits (+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 no easy-to-read byte can be provided because it is in a 4-digit octal number.
So today hex is the more commonly used programming language because two hexadecimal digits specify exactly one byte. On some platforms, powers of two, word size, and instructions are easier to understand. The modern ubiquitous x86 architecture also belongs to this category, but this architecture is rarely used in octal. Although the binary encoding of opcodes for certain attributes becomes more obvious, when displayed in octal, such as ModRM bytes, it is divided into Is 2, 3, and 3 bits, so octal can be used to describe these encodings.
Octal is sometimes used for calculations instead of hexadecimal, perhaps most often on modern Unix systems with file permissions. Its advantage is that it does not require any additional sign digits (the hexadecimal system is base 16, so six additional signs are needed beyond 0-9). It's all used for digital display.
In programming languages, octal literals are often 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 conventions, octal digits are prefixed with @, and the small letter o is added as a suffix, in Intel conventions. DR-DOS debugging uses prefixes to edit octal digits.
For example, the text 73 (octal) can be expressed as 073, o73, q73, 0o73, \ 73, @ 73, & 73, $ 73 or 73o in various languages.
New languages have dropped the prefix 0, and decimals are often represented by leading zeros. Avoid the prefix o being mistaken for zero, and the prefix 0 begins to introduce o to avoid numeric literals with English letters (such as o or q), as these can cause literals to confuse variable names. The prefix 0 o also follows the model-set prefix 0 x for the 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 [21] with the prefix 0 are deprecated.)
Octal digits are used in some programming languages (C, Perl, PostScript ...) for text / graphic representation of byte strings when some byte values (a code page represents non-graphics, have a special meaning in the current context. [3]
The conversion between binary and octal is similar to the conversion between binary and hexadecimal, the difference is that it is required to operate in groups of three digits instead of four digits. Table 2-2 lists the equivalent representations of binary and octal.
To convert octal numbers to binary, replace each octal number with the corresponding three digits in Table 2-2. For example, the result of converting octal 123 to binary is 001010011:
Table 2-2 Binary / octal conversion table
Binary | Octal |
000 | 0 |
001 | 1 |
010 | 2 |
011 | 3 |
100 | 4 |
101 | 5 |
110 | 6 |
111 | 7 |
In order to convert a binary number to octal, you only need to divide the binary string into groups of three digits (padded with zeros if necessary), and then refer to Table 2-2 to replace the three-digit string with The corresponding octal number is sufficient.
If you need to convert an octal number to hexadecimal, you only need to convert the octal number to binary, and then convert to hexadecimal.
Octal to decimal:
Example: Convert octal number 12 to decimal number
Octal to binary:
Rule: According to the order, every 1-digit octal number is rewritten into an equivalent 3-digit binary number, and the order is unchanged.
Example: (17.36) 8 = (001 111 .011 110) 2 = (1111.01111) 2
Octal to Hex
Binary to octal and then to hexadecimal.
Example: (712) 8 = (1110 0101 0) 2 = (1CA) 16
Convert to octal
Binary to octal:
The integer part starts with the least significant digits and consists of 3 digits. When the most significant digits are less than 3 digits, it is filled with 0. Each group can be converted into an octal value. After the conversion, the octal integer is completed.
The decimal part starts with the most significant digit, and consists of 3 digits. When the least significant digit is less than 3 digits, it is filled in with 0. Each group can be converted into an octal value.
Example: (11001111.01111) 2 = (011 001 111.011 110) 2 = (317.36) 8
Hexadecimal to octal:
First use the method of 1 and 4 to convert the hexadecimal to binary; then use the method of 3 and 1 to convert the binary to 8.
Example: (1CA) 16 = (111001010) 2 = (712) 8
Note: The high zero before the decimal point and the low zero after the decimal point can be removed.
Decimal octal
Method 1: Divide by 8 and take the remainder.
Example: Convert the decimal number 115 to an octal number
8 | 115 3
8 | 14 6
8 | 1 1
Results: (115) 10 = (163) 8
Method 2: First use the method of decimal binary, and then convert the binary number to octal number
Example: (115) 10 = (1110011) 2 = (163) 8
Expressions in C
In C, integers have three representations: decimal, octal, and hexadecimal. It starts with the number 0, and the number consisting of 0 ~ 7 is octal. It starts with 0X or 0x and is composed of 0 ~ 9, A ~ F or a ~ f. Except for positive and negative signs, it starts with 1 ~ 9 and is composed of 0 ~ 9 as decimal. 1. Decimal: In addition to the signs that indicate positive and negative, it starts with 1-9 and consists of 0-9. For example, 128, +234, -278. 2, octal: a number starting with 0 and composed of 0-7 For example, 0126,050000.3, hexadecimal: Start with 0X or 0x, and consist of 0 ~ 9, A ~ F or a ~ f. For example, 0x12A, 0x5a000.