Spiegato, Home

Technology and Gadgets

What Is the Gray Code?

  • Published by Spiegato
  • 2 min read

The Gray code is a type of cyclical binary code patented for the first time in 1947, but not given the name Gray code until the early 1950s, in subsequent patent applications. Specifically, the code is a reflected binary code, meaning that the last numbers in the string can be the same as the beginning numbers, but in reverse order, thus allowing for building on and expanding the usefulness of standard or natural binary code. Frank Gray, the Bell Labs researcher for whom the code is named, developed this particular binary numeral system to help control electromechanical switches. Today, Gray code is used in a variety of environments, particularly digital communications where analog signals must be converted to digital mediums.

During the early stages of development for the code, the focus was primarily on the more effective operation of electromechanical switches. Mechanical switches using natural binary code can be difficult to read in terms of position. Several switches can change position at one time, with complicated transitional positions. Depending on the phase of transition, a switch might read in one position when it is actually in a state of transition, on its way to another position. Multiplied by several switches, an incorrect reading of switch position can result in system-wide errors and false information.

Alternatively, only one switch changes position at a time when using Gray code, which eliminates the possibility of false or misleading position information, since only one bit changes at a time. As development of the code continued for several decades after Gray’s initial introduction, additional applications came to light. For example, rotary and optical encoders use Gray code because each sequence or change in position differs by only one bit. Likewise, error correction for digital communication, genetic algorithms, and certain types of maps use Gray code, also due to the single bit change property associated with the code.

A similar reflected binary code was used in the late 1800s in telegraphy. Even earlier, mathematicians used reflected binary code to solve complex mathematical questions or puzzles similar to the Tower of Hanoi and ancient Chinese ring puzzles. Although used, such binary codes were not standardized, patented, or otherwise deemed of proprietary use until Gray’s work in the late 1940s and early 1950s. Bell Labs, in using a vacuum tube instrument invented by Frank Gray, patented the first device in which analog signals were converted to reflected binary code. In the 1953 patent application for the device, known as pulse code communication tube or PCM tube, Bell Labs referenced Gray code officially for the first time.

Key terms in this article

Related articles

  • What is Gray Box Testing?

    Gray box testing is a type of professional testing often used for computer software, which combines certain aspects of black box testing and white box…

  • What is QR Code?

    Computers are widespread, with a great many things being computerized, including things that we don’t normally think of as being computerized. These…

  • What is Machine Code?

    Machine code is the essential or basic language that provides the foundation for all computers currently in operation. Essentially, machine code is based…

  • What Is Code Migration?

    Code migration is the movement of programming code from one system to another. There are three distinct levels of code migration with increasing…

  • What Is Code Signing?

    Hackers frequently take software — whether offline or online — rearrange and change the code to make it malicious, and then upload it online so users…