Returns the integer whose value is the reverse of the lowest 'bits' bits of the integer 'x'.
9988
function reverseBits(x, bits) {
      var y = 0;

      for (var i = 0; i < bits; i++) {
        y = (y << 1) | (x & 1);
        x >>>= 1;
      }

      return y;
    }
984838
def small_integer_from_opcode(opcode)
      return 0  if opcode == "".b # OP_O
      return 0  if opcode == OP_0
      return -1 if opcode == OP_1NEGATE
      if opcode >= OP_1 && opcode <= OP_16
        return opcode - (OP_1 - 1)
      end
      return nil
    end
319836
def bit_reversal(qubits: List[int]) -> Program:
    
    p = Program()
    n = len(qubits)
    for i in range(int(n / 2)):
        p.inst(SWAP(qubits[i], qubits[-i - 1]))
    return p
590958
function is_negative (x) {
        var isOverflowOrNegative = is_overflow(x) || x[9] < 0;
        var leastSignificantBit = x[0] & 1;
        return ((isOverflowOrNegative ? 1 : 0) ^ leastSignificantBit) & 0xFFFFFFFF;
    }
290242
def _reverse(self):
        
        o = self.copy()
        # Clear ok reversed flag
        o._reversed = not o._reversed

        if o.bits == 8:
            # No need for reversing
            return o.copy()

        if o.is_top:
            # A TOP is still a TOP after reversing
            si = o.copy()
            return si

        else:
            if not o.is_integer:
                # We really don't want to do that... but well, sometimes it just happens...
                logger.warning('Reversing a real strided-interval %s is bad', self)

            # Reversing an integer is easy
            rounded_bits = ((o.bits + 7) // 8) * 8
            list_bytes = [ ]
            si = None

            for i in xrange(0, rounded_bits, 8):
                b = o._unrev_extract(min(i + 7, o.bits - 1), i)
                list_bytes.append(b)

            for b in list_bytes:
                si = b if si is None else si.concat(b)
            si.uninitialized = self.uninitialized
            si._reversed = o._reversed
            return si
170172
static protected int getPadBits(
        int bitString)
    {
        int val;

        if (bitString == 0)
        {
            return 7;
        }

        if (bitString > 255)
        {
            val = ((bitString >> 8) & 0xFF);
        }
        else
        {
            val = (bitString & 0xFF);
        }

        int bits = 1;

        while (((val <<= 1) & 0xFF) != 0)
        {
            bits++;
        }

        return 8 - bits;
    }
817621
def coerceBigInt(x):
    
    # BigInt's are easy.
    if isinstance(x, BigInt):
        return x

    # Convert ints and longs using the constructor
    elif isinstance(x, (long, int)):
        return BigInt(x)

    else:
        return None
890395
def reverse(self):
        
        return BBox((self.min_y, self.min_x, self.max_y, self.max_x), crs=self.crs)
1166260
function bits( x ) {
	var b;

	// Convert the input value to a bit string:
	b = div2( x );

	// Left pad the bit string to ensure 8 bits are represented:
	b = lpad( b, NBITS, '0' );

	return b;
}
609521
private final int getLowestSetBit() {
        if (intLen == 0)
            return -1;
        int j, b;
        for (j=intLen-1; (j > 0) && (value[j+offset] == 0); j--)
            ;
        b = value[j+offset];
        if (b == 0)
            return -1;
        return ((intLen-1-j)<<5) + Integer.numberOfTrailingZeros(b);
    }
1205458
function zip_bi_reverse(
  code,	// the value to invert
  len) {	// its bit length
  var res = 0;
  do {
    res |= code & 1;
    code >>= 1;
    res <<= 1;
  } while (--len > 0);
  return res >> 1;
}
622939
public int nextBit(int x) {
        Assert.check(currentState != BitsState.UNKNOWN);
        int windex = x >>> wordshift;
        if (windex >= bits.length) {
            return -1;
        }
        int word = bits[windex] & ~((1 << (x & wordmask))-1);
        while (true) {
            if (word != 0) {
                return (windex << wordshift) + trailingZeroBits(word);
            }
            windex++;
            if (windex >= bits.length) {
                return -1;
            }
            word = bits[windex];
        }
    }
643814
public int indexOf(T x) {
    int r=Arrays.binarySearch(data,x);
    return(r>=0?r:-1);
  }
817394
def _bit_mismatch(int1: int, int2: int) -> int:
    """"""
    for i in range(max(int1.bit_length(), int2.bit_length())):
        if (int1 >> i) & 1 != (int2 >> i) & 1:
            return i
    return -1
571895
public static int whichMin(int[] x) {
        int m = x[0];
        int which = 0;

        for (int i = 1; i < x.length; i++) {
            if (x[i] < m) {
                m = x[i];
                which = i;
            }
        }

        return which;
    }
153487
public int last()
    {
        for (int ii=array.length-1;ii>=0;ii--)
        {
            if (array[ii] != 0)
            {
                for (int jj=Math.min(bits,(ii+1)*8)-1;jj>=0;jj--)
                {
                    if (isSet(jj))
                    {
                        return jj;
                    }
                }
            }
        }
        return -1;
    }
368562
def get_bit(self, position: int):
        

        if position > (self._bit_width - 1):
            raise ValueError('position greater than the bit width')

        if self._value & (1 << position):
            return 1
        else:
            return 0