Quaternary is a numeral system with four as its base. It uses the digits 0, 1, 2, and 3 to represent any real number. Conversion from binary is straightforward.
Four is the largest number within the subitizing range and one of two numbers that is both a square and a highly composite number (the other being thirty-six), making quaternary a convenient choice for a base at this scale. Despite being twice as large, its radix economy is equal to that of binary. However, it fares no better in the localization of prime numbers (the smallest better base being the primorial 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 of rational numbers and irrational numbers. See decimal and binary 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 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
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 | 10000 | 10001 | 10010 | 10011 | 10100 | 10101 | 10110 | 10111 | 11000 | 11001 | 11010 | 11011 | 11100 | 11101 | 11110 | 11111 |
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 | 100000 | 100001 | 100010 | 100011 | 100100 | 100101 | 100110 | 100111 | 101000 | 101001 | 101010 | 101011 | 101100 | 101101 | 101110 | 101111 |
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 | 110000 | 110001 | 110010 | 110011 | 110100 | 110101 | 110110 | 110111 | 111000 | 111001 | 111010 | 111011 | 111100 | 111101 | 111110 | 111111 |
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 | 1000000 | |||||||||||||||
Quaternary | 1000 | |||||||||||||||
Octal | 100 | |||||||||||||||
Hexadecimal | 40 | |||||||||||||||
+ | 1 | 2 | 3 | |
1 | 2 | 3 | 10 | |
2 | 3 | 10 | 11 | |
3 | 10 | 11 | 12 |
2302104 = 10 11 00 10 01 002.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,
23 02 104 = B2416
× | 1 | 2 | 3 | |
1 | 1 | 2 | 3 | |
2 | 2 | 10 | 12 | |
3 | 3 | 12 | 21 |
Although octal and hexadecimal are widely used in computing and computer 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 with byte and nybble, a quaternary digit is sometimes called a crumb.
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 | |||
2 | 0.5 | 0.2 | 2 | |||||
3 | bgcolor=#c0c0c0 | 0.3333... = 0. | bgcolor=#c0c0c0 | 0.1111... = 0. | 3 | |||
2 | 0.25 | 0.1 | 2 | |||||
5 | 0.2 | bgcolor=#c0c0c0 | 0. | 11 | ||||
2, 3 | bgcolor=#c0c0c0 | 0.1 | bgcolor=#c0c0c0 | 0.0 | 2, 3 | |||
7 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 13 | |||
2 | 0.125 | 0.02 | 2 | |||||
3 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 3 | |||
2, 5 | 0.1 | bgcolor=#c0c0c0 | 0.0 | 2, 11 | ||||
11 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 23 | |||
2, 3 | bgcolor=#c0c0c0 | 0.08 | bgcolor=#c0c0c0 | 0.0 | 2, 3 | |||
13 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 31 | |||
2, 7 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0.0 | 2, 13 | |||
3, 5 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0. | 3, 11 | |||
2 | 0.0625 | 0.01 | 2 | |||||
17 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 101 | |||
2, 3 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0.0 | 2, 3 | |||
19 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 103 | |||
2, 5 | 0.05 | bgcolor=#c0c0c0 | 0.0 | 2, 11 | ||||
3, 7 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 3, 13 | |||
2, 11 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0.0 | 2, 23 | |||
23 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 113 | |||
2, 3 | bgcolor=#c0c0c0 | 0.041 | bgcolor=#c0c0c0 | 0.00 | 2, 3 | |||
5 | 0.04 | bgcolor=#c0c0c0 | 0. | 11 | ||||
2, 13 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0.0 | 2, 31 | |||
3 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 3 | |||
2, 7 | bgcolor=#c0c0c0 | 0.03 | bgcolor=#c0c0c0 | 0.0 | 2, 13 | |||
29 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 131 | |||
2, 3, 5 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0.0 | 2, 3, 11 | |||
31 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 133 | |||
2 | 0.03125 | 0.002 | 2 | |||||
3, 11 | bgcolor=#c0c0c0 | 0. | bgcolor=#c0c0c0 | 0. | 3, 23 | |||
2, 17 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0.0 | 2, 101 | |||
5, 7 | bgcolor=#c0c0c0 | 0.0 | bgcolor=#c0c0c0 | 0. | 11, 13 | |||
2, 3 | bgcolor=#c0c0c0 | 0.02 | bgcolor=#c0c0c0 | 0.0 | 2, 3 |
Many or all of the Chumashan languages (spoken by the Native American Chumash 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 of Ventureño language number words up to thirty-two written down by a Spanish priest ca. 1819.
The Kharosthi 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 2D Hilbert 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.
See main article: Bioinformatics. Parallels can be drawn between quaternary numerals and the way genetic code is represented by DNA. The four DNA nucleotides in alphabetical order, abbreviated A, C, G, and T, can be taken to represent the quaternary digits in numerical order 0, 1, 2, and 3. With this encoding, the complementary digit pairs 0↔3, and 1↔2 (binary 00↔11 and 01↔10) match the complementation of the base pairs: A↔T and C↔G and can be stored as data in DNA sequence. For example, the nucleotide sequence GATTACA can be represented by the quaternary number 2033010 (= decimal 9156 or binary 10 00 11 11 00 01 00). The human genome is 3.2 billion base pairs in length.[1]
Quaternary line codes have been used for transmission, from the invention of the telegraph to the 2B1Q code used in modern ISDN circuits.
The GDDR6X standard, developed by Nvidia and Micron, uses quaternary bits to transmit data.[2]
Some computers have used quaternary floating point arithmetic including the Illinois ILLIAC II (1962) and the Digital Field System DFS IV and DFS V high-resolution site survey systems.