Skip main navigation

Hurry, only 9 days left to get one year of Unlimited learning for £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

What are Gray codes?

Watch Dr. Yossi Elran explain what Gray codes are, in this video

When we look at the binary numbers in order we see an interesting phenomenon. Each time we reach a power of 2, all the bits change! When advancing from 1 to 2, we go from 01 in binary code to 10, and when advancing from 3 to 4 we change 011 to 100, and so on.

In digital devices that count things, like the speedometer in a car, this property may be a problem. In any electronic device, there is always a risk that something will malfunction, especially when changes are made, such as when one bit is changed into another. If all the bits are changed at once, the risk is much bigger.

This problem exists also in meters that are based on the decimal system – like a row of cogwheels where each one has the digits 0 to 9 (in old-fashioned speedometers). When the number changes from 9999 to 10000, all the wheels rotate at once, and this raises the risk of a technical malfunction.

This was exactly the motivation for Frank Gray, an American Physicist, to invent a symbology in which in every move between two consecutive numbers, only one digit is changed. Gray’s method is appropriate for any counting system (decimal, binary, etc.), and when it is used in the binary system, it is called “Gray Code”. This of course means that the positions of the bits in the number no longer represent powers of two, so we need to use a table or other means to translate Gray code back into decimal. Watch this video to learn about Gray codes.

This article is from the free online

Maths Puzzles: Cryptarithms, Symbologies and Secret Codes

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now