code: private static int grayToBin(int gray, int bitlength) {
  		int result = 0;
  		for (int i = bitlength-1; i >= 0; --i)
  			result = result|((((0x1<<(i+1))&result)>>>1)^((1<<i)&gray));
  		return result;
  	}
docs: This method converts a gray code encoded int to a standard decimal int
  @param gray gray code encoded int of length bitlength
  bitlength bitlength of gray code
  @return radix 2 encoded integer