WSJT-X/map65/libm65/igray.c
Bill Somerville 280c8344cd
Move project files to map65 sub-directory
Preparation for merging with the wsjtx project repository.
2021-04-09 13:57:41 +01:00

23 lines
315 B
C

#ifdef CVF
extern int __stdcall IGRAY(int *n0, int *idir)
#else
int igray_(int *n0, int *idir)
#endif
{
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);
}