public int DecodeBit(short[] probs, int index) throws IOException
  {
    int prob = probs[index];
    int newBound = (Range >>> 11) * prob;
    if ((Code ^ 0x80000000) < (newBound ^ 0x80000000))
    {
      Range = newBound;
      probs[index] = (short)(prob + (2048 - prob >>> 5));
      if ((Range & 0xFF000000) == 0)
      {
        Code = (Code << 8 | Stream.read());
        Range <<= 8;
      }
      return 0;
    }

    Range -= newBound;
    Code -= newBound;
    probs[index] = (short)(prob - (prob >>> 5));
    if ((Range & 0xFF000000) == 0)
    {
      Code = (Code << 8 | Stream.read());
      Range <<= 8;
    }
    return 1;
  }