(public) returns index of lowest 1-bit (or -1 if none)
768886
function bnGetLowestSetBit() {
for(var i = 0; i < this.t; ++i)
 if(this.data[i] != 0) return i*this.DB+lbit(this.data[i]);
if(this.s < 0) return this.t*this.DB;
return -1;
}
1128634
def index_of_lowest_precedence(operators,associativity=:left)
    lowest = lowest_precedence = nil
    operators.each_with_index do |operator,i|
      operator_string = operator.to_s
      precedence = operator_precedence(operator_string)
      right_associative = @right_operators_regexp && operator_string[@right_operators_regexp]
      if !lowest || (right_associative ? precedence < lowest_precedence : precedence <= lowest_precedence)
        lowest = i
        lowest_precedence = precedence
      end
    end
    lowest
  end
102456
function min(array) {
  var length = array.length;

  if (length === 0) {
    return 0;
  }

  var index = -1;
  var result = array[++index];

  while (++index < length) {
    if (array[index] < result) {
      result = array[index];
    }
  }

  return result;
}
781267
function findLastCommonIndex(xs, ys) {
    for (let i = Math.min(xs.length, ys.length) - 1; i >= 0; --i) {
        if (xs[i] === ys[i]) {
            return i
        }
    }
    return -1
}
253347
private static int getHighBit(int value) {
        if (value <= 0) {
            return -32;
        }

        int bit = 0;

        if (value >= 1 << 16) {
            value >>= 16;
            bit += 16;
        }

        if (value >= 1 << 8) {
            value >>= 8;
            bit += 8;
        }

        if (value >= 1 << 4) {
            value >>= 4;
            bit += 4;
        }

        if (value >= 1 << 2) {
            value >>= 2;
            bit += 2;
        }

        if (value >= 1 << 1) {
            bit += 1;
        }

        return bit;
    }
950732
def _count_righthand_zero_bits(number, bits):
    
    if number == 0:
        return bits
    return min(bits, _compat_bit_length(~number & (number - 1)))
1251998
function (a) {
    var l = a.length, x;
    if (l === 0) { return 0; }
    x = a[l - 1];
    return (l-1) * 32 + sjcl.bitArray.getPartial(x);
  }
1132413
private static int readCode(boolean[] rawbits, int startIndex, int length) {
    int res = 0;
    for (int i = startIndex; i < startIndex + length; i++) {
      res <<= 1;
      if (rawbits[i]) {
        res |= 0x01;
      }
    }
    return res;
  }
761118
private static int indexOfNonDigit(String string, int offset) {
        for (int i = offset; i < string.length(); i++) {
            char c = string.charAt(i);
            if (c < '0' || c > '9') return i;
        }
        return string.length();
    }
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];
        }
    }
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
66801
def _zero_based_index(self, onebased: Union[int, str]) -> int:
        """"""
        result = int(onebased)
        if result > 0:
            result -= 1
        return result
956260
@Override
    public int parity(long[] current) {

        int count = 0;

        for (int i = 0, n = indices.length; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int cmp = compare(current[indices[i]], current[indices[j]]);
                if (cmp == 0)
                    return 0;
                else if (cmp > 0) count++;
            }
        }

        // value is odd, -1 or value is even +1
        return Integer.lowestOneBit(count) == 1 ? -1 : +1;
    }
1184852
public int indexOf(byte b) {
        if (_buf.hasArray()) {
            byte[] array = _buf.array();
            int arrayOffset = _buf.arrayOffset();
            int startAt = arrayOffset + position();
            int endAt = arrayOffset + limit();

            for (int i = startAt; i < endAt; i++) {
                if (array[i] == b) {
                    return i - arrayOffset;
                }
            }
            return -1;
        } else {
            int startAt = _buf.position();
            int endAt = _buf.limit();

            for (int i = startAt; i < endAt; i++) {
                if (_buf.get(i) == b) {
                    return i;
                }
            }
            return -1;
        }
    }
569398
def get_bin_index(self, value):
        """"""
        if value == self.max_value:
            return self.num_bins - 1
        return int((value - self.min_value) / self.bin_size)
55137
int nextIndexOf(char c) {
        // doesn't handle scanning for surrogates
        bufferUp();
        for (int i = bufPos; i < bufLength; i++) {
            if (c == charBuf[i])
                return i - bufPos;
        }
        return -1;
    }
716244
public int nextSetBit(int index) {
        int i = index>>6;
        if (i>=wlen) return -1;
        int subIndex = index & 0x3f;      // index within the word
        long word = bits[i] >> subIndex;  // skip all the bits to the right of index

        if (word!=0) {
            return (i<<6) + subIndex + Long.numberOfTrailingZeros(word);
        }

        while(++i < wlen) {
            word = bits[i];
            if (word!=0) return (i<<6) + Long.numberOfTrailingZeros(word);
        }

        return -1;
    }