convert output to gray code