| Part ofa series on | ||||
| Numeral systems | ||||
|---|---|---|---|---|
| ||||
| List of numeral systems | ||||
Quaternary/kwəˈtɜːrnəri/ is anumeral system withfour as itsbase. It uses thedigits 0, 1, 2, and 3 to represent anyreal number. Conversion frombinary is straightforward.
Four is the largest number within thesubitizing range and one of two numbers that is both a square and ahighly composite number (the other being thirty-six), making quaternary a convenient choice for a base at this scale. Despite being twice as large, itsradix economy is equal to that of binary. However, it fares no better in the localization of prime numbers (the smallest better base being theprimorial base six,senary).
Quaternary shares with all fixed-radix numeral systems many properties, such as the ability to represent any real number with a canonical representation (almost unique) and the characteristics of the representations ofrational numbers andirrational numbers. Seedecimal andbinary for a discussion of these properties.
| Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1,000 | 1,001 | 1,010 | 1,011 | 1,100 | 1,101 | 1,110 | 1,111 |
| Quaternary | 0 | 1 | 2 | 3 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 | 30 | 31 | 32 | 33 |
| Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| Decimal | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| Binary | 10,000 | 10,001 | 10,010 | 10,011 | 10,100 | 10,101 | 10,110 | 10,111 | 11,000 | 11,001 | 11,010 | 11,011 | 11,100 | 11,101 | 11,110 | 11,111 |
| Quaternary | 100 | 101 | 102 | 103 | 110 | 111 | 112 | 113 | 120 | 121 | 122 | 123 | 130 | 131 | 132 | 133 |
| Octal | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
| Hexadecimal | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 1A | 1B | 1C | 1D | 1E | 1F |
| Decimal | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
| Binary | 100,000 | 100,001 | 100,010 | 100,011 | 100,100 | 100,101 | 100,110 | 100,111 | 101,000 | 101,001 | 101,010 | 101,011 | 101,100 | 101,101 | 101,110 | 101,111 |
| Quaternary | 200 | 201 | 202 | 203 | 210 | 211 | 212 | 213 | 220 | 221 | 222 | 223 | 230 | 231 | 232 | 233 |
| Octal | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
| Hexadecimal | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 2A | 2B | 2C | 2D | 2E | 2F |
| Decimal | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
| Binary | 110,000 | 110,001 | 110,010 | 110,011 | 110,100 | 110,101 | 110,110 | 110,111 | 111,000 | 111,001 | 111,010 | 111,011 | 111,100 | 111,101 | 111,110 | 111,111 |
| Quaternary | 300 | 301 | 302 | 303 | 310 | 311 | 312 | 313 | 320 | 321 | 322 | 323 | 330 | 331 | 332 | 333 |
| Octal | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
| Hexadecimal | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 3A | 3B | 3C | 3D | 3E | 3F |
| Decimal | 64 | |||||||||||||||
| Binary | 1,000,000 | |||||||||||||||
| Quaternary | 1,000 | |||||||||||||||
| Octal | 100 | |||||||||||||||
| Hexadecimal | 40 | |||||||||||||||
| + | 1 | 2 | 3 |
| 1 | 2 | 3 | 10 |
| 2 | 3 | 10 | 11 |
| 3 | 10 | 11 | 12 |
As with theoctal andhexadecimal numeral systems, quaternary has a special relation to thebinary numeral system. Eachradix four, eight, and sixteen is apower of two, so the conversion to and from binary is implemented by matching each digit with two, three, or four binary digits, orbits. For example, in quaternary,
Since sixteen is a power of four, conversion between these bases can be implemented by matching each hexadecimal digit with two quaternary digits. In the above example,
| × | 1 | 2 | 3 |
| 1 | 1 | 2 | 3 |
| 2 | 2 | 10 | 12 |
| 3 | 3 | 12 | 21 |
Although octal and hexadecimal are widely used incomputing andcomputer programming in the discussion and analysis of binary arithmetic and logic, quaternary does not enjoy the same status.
Although quaternary has limited practical use, it can be helpful if it is ever necessary to perform hexadecimal arithmetic without a calculator. Each hexadecimal digit can be turned into a pair of quaternary digits. Then, arithmetic can be performed relatively easily before converting the end result back to hexadecimal. Quaternary is convenient for this purpose, since numbers have only half the digit length compared to binary, while still having very simple multiplication and addition tables with only three unique non-trivial elements.
By analogy withbyte andnybble, a quaternary digit is sometimes called acrumb.
Due to having only factors of two, many quaternary fractions have repeating digits, although these tend to be fairly simple:
| Decimal base Prime factors of the base:2,5 Prime factors of one below the base:3 Prime factors of one above the base:11 Other prime factors:7 13 17 19 23 29 31 | Quaternary base Prime factors of the base:2 Prime factors of one below the base:3 Prime factors of one above the base:5 (=114) Other prime factors:13 23 31 101 103 113 131 133 | ||||
| Fraction | Prime factors of the denominator | Positional representation | Positional representation | Prime factors of the denominator | Fraction |
| 1/2 | 2 | 0.5 | 0.2 | 2 | 1/2 |
| 1/3 | 3 | 0.3333... =0.3 | 0.1111... =0.1 | 3 | 1/3 |
| 1/4 | 2 | 0.25 | 0.1 | 2 | 1/10 |
| 1/5 | 5 | 0.2 | 0.03 | 11 | 1/11 |
| 1/6 | 2,3 | 0.16 | 0.02 | 2,3 | 1/12 |
| 1/7 | 7 | 0.142857 | 0.021 | 13 | 1/13 |
| 1/8 | 2 | 0.125 | 0.02 | 2 | 1/20 |
| 1/9 | 3 | 0.1 | 0.013 | 3 | 1/21 |
| 1/10 | 2,5 | 0.1 | 0.012 | 2,11 | 1/22 |
| 1/11 | 11 | 0.09 | 0.01131 | 23 | 1/23 |
| 1/12 | 2,3 | 0.083 | 0.01 | 2,3 | 1/30 |
| 1/13 | 13 | 0.076923 | 0.010323 | 31 | 1/31 |
| 1/14 | 2,7 | 0.0714285 | 0.0102 | 2,13 | 1/32 |
| 1/15 | 3,5 | 0.06 | 0.01 | 3,11 | 1/33 |
| 1/16 | 2 | 0.0625 | 0.01 | 2 | 1/100 |
| 1/17 | 17 | 0.0588235294117647 | 0.0033 | 101 | 1/101 |
| 1/18 | 2,3 | 0.05 | 0.0032 | 2,3 | 1/102 |
| 1/19 | 19 | 0.052631578947368421 | 0.003113211 | 103 | 1/103 |
| 1/20 | 2,5 | 0.05 | 0.003 | 2,11 | 1/110 |
| 1/21 | 3,7 | 0.047619 | 0.003 | 3,13 | 1/111 |
| 1/22 | 2,11 | 0.045 | 0.002322 | 2,23 | 1/112 |
| 1/23 | 23 | 0.0434782608695652173913 | 0.00230201121 | 113 | 1/113 |
| 1/24 | 2,3 | 0.0416 | 0.002 | 2,3 | 1/120 |
| 1/25 | 5 | 0.04 | 0.0022033113 | 11 | 1/121 |
| 1/26 | 2,13 | 0.0384615 | 0.0021312 | 2,31 | 1/122 |
| 1/27 | 3 | 0.037 | 0.002113231 | 3 | 1/123 |
| 1/28 | 2,7 | 0.03571428 | 0.0021 | 2,13 | 1/130 |
| 1/29 | 29 | 0.0344827586206896551724137931 | 0.00203103313023 | 131 | 1/131 |
| 1/30 | 2,3,5 | 0.03 | 0.002 | 2,3,11 | 1/132 |
| 1/31 | 31 | 0.032258064516129 | 0.00201 | 133 | 1/133 |
| 1/32 | 2 | 0.03125 | 0.002 | 2 | 1/200 |
| 1/33 | 3,11 | 0.03 | 0.00133 | 3,23 | 1/201 |
| 1/34 | 2,17 | 0.02941176470588235 | 0.00132 | 2,101 | 1/202 |
| 1/35 | 5,7 | 0.0285714 | 0.001311 | 11,13 | 1/203 |
| 1/36 | 2,3 | 0.027 | 0.0013 | 2,3 | 1/210 |
Many or all of theChumashan languages (spoken by the Native AmericanChumash peoples) originally used a quaternary numeral system, in which the names for numbers were structured according to multiples of four and sixteen, instead of ten. There is a surviving list ofVentureño language number words up to thirty-two written down by a Spanish priest ca. 1819.[1]
TheKharosthi numerals (from the languages of the tribes of Pakistan and Afghanistan) have a partial quaternary numeral system from one to ten.
Quaternary numbers are used in the representation of 2DHilbert curves. Here, a real number between 0 and 1 is converted into the quaternary system. Every single digit now indicates in which of the respective four sub-quadrants the number will be projected.
Parallels can be drawn between quaternary numerals and the waygenetic code is represented byDNA. The four DNAnucleotides inalphabetical order, abbreviatedA,C,G, andT, can be taken to represent the quaternary digits innumerical order 0, 1, 2, and 3. With this encoding, thecomplementary digit pairs 0↔3, and 1↔2 (binary 00↔11 and 01↔10) match the complementation of thebase pairs: A↔T and C↔G and can be stored as data in DNA sequence.[2] For example, the nucleotide sequence GATTACA can be represented by the quaternary number 2033010 (=decimal 9156 orbinary 10 00 11 11 00 01 00). Thehuman genome is 3.2 billion base pairs in length.[3]
Quaternaryline codes have been used for transmission, from theinvention of the telegraph to the2B1Q code used in modernISDN circuits.
The GDDR6X standard, developed byNvidia andMicron, uses quaternary bits to transmit data.[4]
Some computers have usedquaternary floating point arithmetic including theIllinois ILLIAC II (1962)[5] and the Digital Field System DFS IV and DFS V high-resolution site survey systems.[6]
[...] Systems such as the [Digital Field System] DFS IV and DFS V were quaternary floating-point systems and used gain steps of 12 dB. [...](256 pages)