(C++) IntToGray

February 24, 2017 · View on GitHub

 

 

 

 

 

(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

 

  • Wikipedia's page about Gray Codes

 

 

 

 

 

 

Contents

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