private int Dcode(int distance) { int num = 0; while (distance >= 4) { num += 2; distance = distance >> 1; } return (num + distance); }