Would the below algorithm work for when n = 21,000,000?
From URL

http://computerprogrammingforum.com/42vhdl/7c45480b2bed31da.htmHere's the best algorithm I've come up with that works with any word
width. Assuming that the counter is n bits wide,
A is A[n1] A[n2] ... A[2] A[1] A[0] and is the current value.
B is B[n1] B[n2] ... B[2] B[1] B[0] and is the next value.
First, calaulate a parity bit P of A.
P = A[0] XOR A[1] XOR A[2] ... XOR A[n1].
Then,
B[0] = NOT A[0] XOR P
B[1] = A[1] XOR (A[0] AND P)
B[2] = A[2] XOR (A[1] AND NOT A[0] AND P)
B[3] = A[3] XOR (A[2] AND NOT A[1] AND NOT A[0] AND P)
The pattern that emerges is
B[k] = A[k] XOR (A[k1] AND NOT A[k2] AND NOT A[k3] ... AND NOT A[0]
AND P)
except for k = n1 where the A[k1] term is left out so that
B[n1] = A[n1] XOR (NOT A[n3] AND NOT A[n4] ... AND NOT A[0] AND P)
.
On Thursday, March 28, 2013 10:20:09 AM UTC4, amslo...@gmail.com wrote:
Hi  Are there any gray code implementations or algorithms in GO that you
can point me to? I am looking for it work when n = 21,000,000.

You received this message because you are subscribed to the Google Groups "golangnuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golangnuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.