A Gray Code Converter Applet


The gray code number system has the property that each number i's successor and predecessor numbers differ from i in just one bit. To illustrate, the applet below lets you enter a decimal number and find the corresponding gray code value, or vice versa:

By entering a sequence of consecutive decimal values (e.g., 0, 1, 2, 3, 4, 5, 6, 7), you can determine the corresponding consecutive gray-code numbers. Note that for any two consecutive decimal numbers, the base-2 representation of the corresponding gray code values differ in exactly 1 bit.

These gray code numbers can be used to map an alternative topology like a ring onto a hypercube. For example, a degree 3 hypercube has 8 nodes. To map a ring onto those 8 nodes, we visit them in order of the gray code numbers corresponding to the consecutive decimal values 0 through 7:

  000, 001, 011, 010, 110, 111, 101, 100
and then return to the first node (000).

Since an N-dimensional hypercube consists of two N-1-dimensional hypercubes, we can assign each node in an N-dimensional hypercube a gray-code number using this methodology:

In an N-dimensional hypercube, each of the low-order N bits in a node's gray-code number can be associated with a different dimension of the hypercube, and each dimension corresponds to a different link for that node. For a hypercube, node whose decimal number is i, the bit that is different between gray-code(i) and gray-code(i+1) tells us which link we should follow from i to visit the next node in the ring.


Back to the
Ohm Home Page
Back to the
Ohm Project Page
Back to the
Ohm FAQ Page
Joel Adams'
Hypercube Applet Page

This page maintained by Joel Adams.