Binary code

Last updated
The word 'Wikipedia' represented in ASCII binary code, made up of 9 bytes (72 bits). Wikipedia in binary.gif
The word 'Wikipedia' represented in ASCII binary code, made up of 9 bytes (72 bits).

A binary code represents text, computer processor instructions, or any other data using a two-symbol system. The two-symbol system used is often "0" and "1" from the binary number system. The binary code assigns a pattern of binary digits, also known as bits, to each character, instruction, etc. For example, a binary string of eight bits can represent any of 256 possible values and can, therefore, represent a wide variety of different items.

Plain text file format

In computing, plain text is a loose term for data that represent only characters of readable material but not its graphical representation nor other objects. It may also include a limited number of characters that control simple arrangement of text, such as spaces, line breaks, or tabulation characters. Plain text is different from formatted text, where style information is included; from structured text, where structural parts of the document such as paragraphs, sections, and the like are identified; and from binary files in which some portions must be interpreted as binary objects.

Data facts represented for handling

Data are individual units of information . A datum describes a single quality or quantity of some object or phenomenon. In analytical processes, data are represented by variables.

Binary number system that represents numeric values using two symbols; 0 and 1

In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: typically "0" (zero) and "1" (one).


In computing and telecommunications, binary codes are used for various methods of encoding data, such as character strings, into bit strings. Those methods may use fixed-width or variable-width strings. In a fixed-width binary code, each letter, digit, or other character is represented by a bit string of the same length; that bit string, interpreted as a binary number, is usually displayed in code tables in octal, decimal or hexadecimal notation. There are many character sets and many character encodings for them.

In coding theory a variable-length code is a code which maps source symbols to a variable number of bits.

Octal positional notation

The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7. Octal numerals can be made from binary numerals by grouping consecutive binary digits into groups of three. For example, the binary representation for decimal 74 is 1001010. Two zeroes can be added at the left: (00)1 001 010, corresponding the octal digits 1 1 2, yielding the octal representation 112.

Decimal Numeral system with ten as its base

The decimal numeral system is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral system. The way of denoting numbers in the decimal system is often referred to as decimal notation.

A bit string, interpreted as a binary number, can be translated into a decimal number. For example, the lower case a, if represented by the bit string 01100001 (as it is in the standard ASCII code), can also be represented as the decimal number "97".

Letter case Distinction between alphabetic letters in taller, "upper" case and shorter "lower" case

Letter case is the distinction between the letters that are in larger upper case and smaller lower case in the written representation of certain languages. The writing systems that distinguish between the upper and lower case have two parallel sets of letters, with each letter in one set usually having an equivalent in the other set. The two case variants are alternative representations of the same letter: they have the same name and pronunciation and are treated identically when sorting in alphabetical order.

ASCII American computer character encoding

ASCII, abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Most modern character-encoding schemes are based on ASCII, although they support many additional characters.

History of binary code

Gottfried Leibniz Gottfried Wilhelm Leibniz, Bernhard Christoph Francke.jpg
Gottfried Leibniz

The modern binary number system, the basis for binary code, was invented by Gottfried Leibniz in 1689 and appears in his article Explication de l'Arithmétique Binaire. The full title is translated into English as the "Explanation of the binary arithmetic", which uses only the characters 1 and 0, with some remarks on its usefulness, and on the light it throws on the ancient Chinese figures of Fu Xi." [1] (1703). Leibniz's system uses 0 and 1, like the modern binary numeral system. Leibniz encountered the I Ching through French Jesuit Joachim Bouvet and noted with fascination how its hexagrams correspond to the binary numbers from 0 to 111111, and concluded that this mapping was evidence of major Chinese accomplishments in the sort of philosophical mathematics he admired. [2] [3] Leibniz saw the hexagrams as an affirmation of the universality of his own religious belief. [3]

<i>I Ching</i> divinatory text from the Zhou dynasty of China that attaches interpretations to 64 hexagrams

The I Ching or Yi Jing, also known as Classic of Changes or Book of Changes, is an ancient Chinese divination text and the oldest of the Chinese classics. Possessing a history of more than two and a half millennia of commentary and interpretation, the I Ching is an influential text read throughout the world, providing inspiration to the worlds of religion, psychoanalysis, literature, and art. Originally a divination manual in the Western Zhou period (1000–750 BC), over the course of the Warring States period and early imperial period (500–200 BC) it was transformed into a cosmological text with a series of philosophical commentaries known as the "Ten Wings". After becoming part of the Five Classics in the 2nd century BC, the I Ching was the subject of scholarly commentary and the basis for divination practice for centuries across the Far East, and eventually took on an influential role in Western understanding of Eastern thought.

Joachim Bouvet French Jesuit active in China

Joachim Bouvet was a French Jesuit who worked in China, and the leading member of the Figurist movement.

Hexagram star polygon

A hexagram (Greek) or sexagram (Latin) is a six-pointed geometric star figure with the Schläfli symbol {6/2}, 2{3}, or {{3}}. Since there are no true regular continuous hexagrams, the term is instead used to refer to the compound figure of two equilateral triangles shown to the right. The intersection is a regular hexagon.

Binary numerals were central to Leibniz's theology. He believed that binary numbers were symbolic of the Christian idea of creatio ex nihilo or creation out of nothing. [4] Leibniz was trying to find a system that converts logic’s verbal statements into a pure mathematical one. After his ideas were ignored, he came across a classic Chinese text called I Ching or ‘Book of Changes’, which used a type of binary code. The book had confirmed his theory that life could be simplified or reduced down to a series of straightforward propositions. He created a system consisting of rows of zeros and ones. During this time period, Leibniz had not yet found a use for this system. [5]

<i>Ex nihilo</i> A Latin phrase meaning "out of nothing"

Ex nihilo is a Latin phrase meaning "out of nothing". It often appears in conjunction with the concept of creation, as in creatio ex nihilo, meaning "creation out of nothing", chiefly in philosophical or theological contexts, but it also occurs in other fields.

Binary systems predating Leibniz also existed in the ancient world. The aforementioned I Ching that Leibniz encountered dates from the 9th century BC in China. [6] The binary system of the I Ching, a text for divination, is based on the duality of yin and yang. [7] Slit drums with binary tones are used to encode messages across Africa and Asia. [7] The Indian scholar Pingala (around 5th–2nd centuries BC) developed a binary system for describing prosody in his Chandashutram. [8] [9]

Yin and yang Philosophical concept of dualism in ancient Chinese philosophy

In Chinese philosophy, yin and yang is a concept of dualism in ancient Chinese philosophy, describing how seemingly opposite or contrary forces may actually be complementary, interconnected, and interdependent in the natural world, and how they may give rise to each other as they interrelate to one another. In Chinese cosmology, the universe creates itself out of a primary chaos of material energy, organized into the cycles of Yin and Yang and formed into objects and lives. Yin is the receptive and Yang the active principle, seen in all forms of change and difference such as the annual cycle, the landscape, sexual coupling, the formation of both men and women as characters, and sociopolitical history.

Slit drum idiophone

A slit drum is a hollow percussion instrument. In spite of the name, it is not a true drum but an idiophone, usually carved or constructed from bamboo or wood into a box with one or more slits in the top. Most slit drums have one slit, though two and three slits occur. If the resultant tongues are different width or thicknesses, the drum will produce two different pitches. It is used throughout Africa, Southeast Asia, and Oceania. In Africa such drums, strategically situated for optimal acoustic transmission, have been used for long-distance communication.

Acharya Pingalapiṅgala) was an ancient Indian mathematician who authored the Chandaḥśāstra, the earliest known treatise on Sanskrit prosody.

George Boole George Boole color.jpg
George Boole

The residents of the island of Mangareva in French Polynesia were using a hybrid binary-decimal system before 1450. [10] In the 11th century, scholar and philosopher Shao Yong developed a method for arranging the hexagrams which corresponds, albeit unintentionally, to the sequence 0 to 63, as represented in binary, with yin as 0, yang as 1 and the least significant bit on top. The ordering is also the lexicographical order on sextuples of elements chosen from a two-element set. [11]

In 1605 Francis Bacon discussed a system whereby letters of the alphabet could be reduced to sequences of binary digits, which could then be encoded as scarcely visible variations in the font in any random text. [12] Importantly for the general theory of binary encoding, he added that this method could be used with any objects at all: "provided those objects be capable of a twofold difference only; as by Bells, by Trumpets, by Lights and Torches, by the report of Muskets, and any instruments of like nature". [12]

George Boole published a paper in 1847 called 'The Mathematical Analysis of Logic' that describes an algebraic system of logic, now known as Boolean algebra. Boole's system was based on binary, a yes-no, on-off approach that consisted of the three most basic operations: AND, OR, and NOT. [13] This system was not put into use until a graduate student from Massachusetts Institute of Technology, Claude Shannon, noticed that the Boolean algebra he learned was similar to an electric circuit. Shannon wrote his thesis in 1937, which implemented his findings. Shannon's thesis became a starting point for the use of the binary code in practical applications such as computers, electric circuits, and more. [14]

Other forms of binary code

Daoist Bagua Bagua-name-earlier.svg
Daoist Bagua

The bit string is not the only type of binary code: in fact, a binary system in general, is any system that allows only two choices such as a switch in an electronic system or a simple true or false test.


Braille is a type of binary code that is widely used by the blind to read and write by touch, named for its creator, Louis Braille. This system consists of grids of six dots each, three per column, in which each dot has two states: raised or not raised. The different combinations of raised and flattened dots are capable of representing all letters, numbers, and punctuation signs.


The bagua are diagrams used in feng shui, Taoist cosmology and I Ching studies. The ba gua consists of 8 trigrams; meaning 8 and guà meaning divination figure. The same word is used for the 64 guà (hexagrams). Each figure combines three lines (yáo) that are either broken (yin) or unbroken (yang). The relationships between the trigrams are represented in two arrangements, the primordial, "Earlier Heaven" or "Fuxi" bagua, and the manifested, "Later Heaven,"or "King Wen" bagua. [15] (See also, the King Wen sequence of the 64 hexagrams).

Coding systems

ASCII code

The American Standard Code for Information Interchange (ASCII), uses a 7-bit binary code to represent text and other characters within computers, communications equipment, and other devices. Each letter or symbol is assigned a number from 0 to 127. For example, lowercase "a" is represented by 1100001 as a bit string (which is "97" in decimal).

Binary-coded decimal

Binary-coded decimal (BCD) is a binary encoded representation of integer values that uses a 4-bit nibble to encode decimal digits. Four binary bits can encode up to 16 distinct values; but, in BCD-encoded numbers, only the first ten values in each nibble are legal, and encode the decimal digits zero, through nine. The remaining six values are illegal and may cause either a machine exception or unspecified behavior, depending on the computer implementation of BCD arithmetic.

BCD arithmetic is sometimes preferred to floating-point numeric formats in commercial and financial applications where the complex rounding behaviors of floating-point numbers is inappropriate. [16]

Early uses of binary codes

Current uses of binary

Most modern computers use binary encoding for instructions and data. CDs, DVDs, and Blu-ray Discs represent sound and video digitally in binary form. Telephone calls are carried digitally on long-distance and mobile phone networks using pulse-code modulation, and on voice over IP networks.

Weight of binary codes

The weight of a binary code, as defined in the table of constant-weight codes, [18] is the Hamming weight of the binary words coding for the represented words or sequences.

See also

Related Research Articles

Binary-coded decimal class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign or for other indications (e.g., error or overflow)

In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign or for other indications.

Floating-point arithmetic computer format for representing real numbers

In computing, floating-point arithmetic (FP) is arithmetic using formulaic representation of real numbers as an approximation to support a trade-off between range and precision. For this reason, floating-point computation is often found in systems which include very small and very large real numbers, which require fast processing times. A number is, in general, represented approximately to a fixed number of significant digits and scaled using an exponent in some fixed base; the base for the scaling is normally two, ten, or sixteen. A number that can be represented exactly is of the following form:

Hexadecimal numerical system on base 16

In mathematics and computing, hexadecimal is a positional system that represents numbers using a base of 16. Unlike the common way of representing numbers with ten symbols, it uses sixteen distinct symbols, most often the symbols "0"–"9" to represent values zero to nine, and "A"–"F" to represent values ten to fifteen.

Nibble group of four bits (half a "byte"); unit of information

In computing, a nibble (occasionally nybble or nyble to match the spelling of byte) is a four-bit aggregation, or half an octet. It is also known as half-byte or tetrade. In a networking or telecommunication context, the nibble is often called a semi-octet, quadbit, or quartet. A nibble has sixteen (24) possible values. A nibble can be represented by a single hexadecimal digit and called a hex digit.

A computer number format is the internal representation of numeric values in digital computer and calculator hardware and software. Normally, numeric values are stored as groupings of bits, named for the number of bits that compose them. The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer; the bit format used by the computer's instruction set generally requires conversion for external use such as printing and display. Different types of processors may have different internal representations of numerical values. Different conventions are used for integer and real numbers. Most calculations are carried out with number formats that fit into a processor register, but some software systems allow representation of arbitrarily large numbers using multiple words of memory.

Ternary numeral system numeral system, has three as its base

The ternary numeral system has three as its base. Analogous to a bit, a ternary digit is a trit. One trit is equivalent to log2 3 bits of information.

Quaternary numeral system base-4 numeral system. It uses the digits 0, 1, 2 and 3 to represent any real number

Quaternary is the base-4 numeral system. It uses the digits 0, 1, 2 and 3 to represent any real number.

The IEEE Standard for Floating-Point Arithmetic is a technical standard for floating-point arithmetic established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). The standard addressed many problems found in the diverse floating-point implementations that made them difficult to use reliably and portably. Many hardware floating-point units use the IEEE 754 standard.

Excess-3, 3-excess or 10-excess-3 binary code or Stibitz code is a self-complementary binary-coded decimal (BCD) code and numeral system. It is a biased representation. Excess-3 code was used on some older computers as well as in cash registers and hand-held portable electronic calculators of the 1970s, among other uses.

Binary data is data whose unit can take on only two possible states, traditionally labeled as 0 and 1 in accordance with the binary numeral system and Boolean algebra.

Chen–Ho encoding is a memory-efficient alternate system of binary encoding for decimal digits.

Densely packed decimal (DPD) is an efficient method for binary encoding decimal digits.

Decimal floating-point (DFP) arithmetic refers to both a representation and operations on decimal floating-point numbers. Working directly with decimal (base-10) fractions can avoid the rounding errors that otherwise typically occur when converting between decimal fractions and binary (base-2) fractions.

Decimal computer computer using decimal (not binary) as its primary coding system;can represent numbers,addresses in decimal as well as providing instructions to operate on those numbers,addresses directly in decimal,without conversion to a pure binary representation

Decimal computers are computers which can represent numbers and addresses in decimal as well as providing instructions to operate on those numbers and addresses directly in decimal, without conversion to a pure binary representation. Some also had a variable wordlength, which enabled operations on numbers with a large number of digits.

In computing, decimal32 is a decimal floating-point computer numbering format that occupies 4 bytes in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations. Like the binary16 format, it is intended for memory saving storage.

In computing, decimal64 is a decimal floating-point computer numbering format that occupies 8 bytes in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.

In computing, decimal128 is a decimal floating-point computer numbering format that occupies 16 bytes in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.

BCD, also called alphanumeric BCD, alphameric BCD, BCD Interchange Code, or BCDIC, is a family of representations of numerals, uppercase Latin letters, and some special and control characters as six-bit character codes.


  1. Leibniz G., Explication de l'Arithmétique Binaire, Die Mathematische Schriften, ed. C. Gerhardt, Berlin 1879, vol.7, p.223; Engl. transl.
  2. Aiton, Eric J. (1985). Leibniz: A Biography. Taylor & Francis. pp. 245–8. ISBN   978-0-85274-470-3.
  3. 1 2 J.E.H. Smith (2008). Leibniz: What Kind of Rationalist?: What Kind of Rationalist?. Springer. p. 415. ISBN   978-1-4020-8668-7.
  4. Yuen-Ting Lai (1998). Leibniz, Mysticism and Religion. Springer. pp. 149–150. ISBN   978-0-7923-5223-5.
  5. "Gottfried Wilhelm Leibniz (1646 - 1716)".
  6. Edward Hacker; Steve Moore; Lorraine Patsco (2002). I Ching: An Annotated Bibliography. Routledge. p. 13. ISBN   978-0-415-93969-0.
  7. 1 2 Jonathan Shectman (2003). Groundbreaking Scientific Experiments, Inventions, and Discoveries of the 18th Century. Greenwood Publishing. p. 29. ISBN   978-0-313-32015-6.
  8. Sanchez, Julio; Canton, Maria P. (2007). Microcontroller programming: the microchip PIC. Boca Raton, Florida: CRC Press. p. 37. ISBN   978-0-8493-7189-9.
  9. W. S. Anglin and J. Lambek, The Heritage of Thales, Springer, 1995, ISBN   0-387-94544-X
  10. Bender, Andrea; Beller, Sieghard (16 December 2013). "Mangarevan invention of binary steps for easier calculation". Proceedings of the National Academy of Sciences. 111 (4): 1322–1327. doi:10.1073/pnas.1309160110. PMC   3910603 . PMID   24344278.
  11. Ryan, James A. (January 1996). "Leibniz' Binary System and Shao Yong's "Yijing"". Philosophy East and West. 46 (1): 59–90. doi:10.2307/1399337. JSTOR   1399337.
  12. 1 2 Bacon, Francis (1605). "The Advancement of Learning". London. pp. Chapter 1.
  13. "What's So Logical About Boolean Algebra?".
  14. "Claude Shannon (1916 - 2001)".
  15. Wilhelm, Richard (1950). The I Ching or Book of Changes. trans. by Cary F. Baynes, forward by C. G. Jung, preface to 3rd ed. by Hellmut Wilhelm (1967). Princeton, NJ: Princeton University Press. pp. 266, 269. ISBN   978-0-691-09750-3.
  16. Cowlishaw, Mike F. (2015) [1981,2008]. "General Decimal Arithmetic". IBM. Retrieved 2016-01-02.
  17. 1 2 3 Glaser 1971
  18. Table of Constant Weight Binary Codes