Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) IntToGray

 

IntToGray is a bit operation conversion code snippet to convert an integer to Gray code. To convert a Gray code to an integer value, use GrayToInt.

 

//From http://www.richelbilderbeek.nl/CppIntToGray.htm
int IntToGray(const int i)
{
  return (i ^ (i>>1));
}

 

 

 

 

 

External links

 

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict