Quaternary is the base- numeral system. It uses the digits 0, 1, 2 and 3 to represent any real number. Four is the largest number within the subitizing range and one of two numbers that is both a square and a highly composite number, 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. Quaternary shares with all fixed-radix numeral systems many properties, such as the ability to represent any real number with a canonical representation and the characteristics of the representations of rational numbers and irrational numbers. See decimal and binary for a discussion of these properties.
As with the octal and hexadecimal numeral systems, quaternary has a special relation to the binary numeral system. Each radix 4, 8 and 16 is a power of 2, so the conversion to and from binary is implemented by matching each digit with 2, 3 or 4 binary digits, or bits. For example, in base 4, Since 16 is a power of 4, conversion between these bases can be implemented by matching each hexadecimal digit with 2 quaternary digits. In the above example, 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, and 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.
×
1
2
3
1
1
2
3
2
2
10
12
3
3
12
21
By analogy with byte and nybble, a quaternary digit is sometimes called a crumb.
Fractions
Due to having only factors of two, many quaternary fractions have repeating digits, although these tend to be fairly simple:
Many or all of the Chumashan languages originally used a base 4 counting system, in which the names for numbers were structured according to multiples of 4 and 16. There is a surviving list of Ventureño languagenumber words up to 32 written down by a Spanish priest ca. 1819. The Kharosthi numerals have a partial base 4 counting system from 1 to decimal 10.
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 4 sub-quadrants the number will be projected.
Genetics
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 :wikt:complementary|complementary digit pairs 0↔3, and 1↔2 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.
Data transmission
Quaternary line codes have been used for transmission, from the invention of the telegraph to the 2B1Q code used in modern ISDN circuits.