# counting in grey code

Status
Not open for further replies.

#### patchquinn

##### Junior Member level 1
what is grey code with example

hi, this might seem like a dumb question, but is there a convention for counting in the grey code for an arbitrary number of bits? For example with 3 bits there are number of possibilities , 000, 001, 011, 010, 110,111,101,100
0r
000,001,011,010,110,100,101,111
when you get to four bits it gets more confusing, I assume you try to have the lower value numbers first. But there must be some sort of algorithm. cant seem to find one on the web
cheers

#### dsp_

##### Member level 3
recursive grey code

Take the line 00,01,11,10
Reverse it 10,11,01,00
write a zero before each element of the first line 000,001,011,010
write a one before each element of the reversed line 110,111,101,100
and concatenate both
000,001,011,010,110,111,101,100

EDIT: but u cant say that finding generation rules on gray code is very hard.. google:"gray code" -> the fifth entry leads to http://yagni.com/graycode/

but thanks to you now i dont only know the recursive approach thanks

HTH
dsp_

#### patchquinn

##### Junior Member level 1
thanks dsp_,
and regarding google search, being Irish I have been spelling it grey code rather than gray code, doh!

Status
Not open for further replies.