js8call/.svn/pristine/0a/0a185b6bb9a4d7cf1d716893920bff29fae3ed98.svn-base

19 lines
244 B
Plaintext
Raw Normal View History

2018-02-08 21:28:33 -05:00
int igray_(int *n0, int *idir)
{
int n;
unsigned long sh;
unsigned long nn;
n=*n0;
if(*idir>0) return (n ^ (n >> 1));
sh = 1;
nn = (n >> sh);
while (nn > 0) {
n ^= nn;
sh <<= 1;
nn = (n >> sh);
}
return (n);
}