Addition of 1 to a binary array
760029
function binaddone(bin){
  var len = bin.length;
  var result = new Array(len + 1);
  var c = true;   // carry bit
  var i = len;   // i points at the bit in bin one after the untouched bit
  while(c && (i > 0)){
    i--;
    c = bin[i];
    result[i+1] = !c;
  }
  if(i){
    // Return remaining untouched bin concatenated with the touched bits
    return bin.slice(0, i).concat(result.slice(i+1));
  }else{
    if(c){
      // Return full result with carry as prefix
      result[0] = true;
      return result;
    }else{
      // Return result without carry
      return result.slice(1);
    }
  }
}
1023471
function binaryFindLarger(item, list) {
	var min = 0;
	var max = list.length - 1;
	var guess;

	var bitwise = (max <= 2147483647) ? true : false;
	if (bitwise) {
		while (min <= max) {
			guess = (min + max) >> 1;
			if (list[guess] === item) { return guess; }
			else {
				if (list[guess] < item) { min = guess + 1; }
				else { max = guess - 1; }
			}
		}
	} else {
		while (min <= max) {
			guess = Math.floor((min + max) / 2);
			if (list[guess] === item) { return guess; }
			else {
				if (list[guess] < item) { min = guess + 1; }
				else { max = guess - 1; }
			}
		}
	}

	return (min == list.length) ? null : min;

//	return -1;
}
792683
function bininputtobin(bininput){
  var len = bininput.length;
  if(len == 0){return filledarray(false, 1);}
  var bin = new Array(len);
  var j = 0;
  for (var i = 0; i < len; i++){
    switch (bininput[i]){
    case '0': bin[j++] = false; break;
    case '1': bin[j++] = true; break;
    default: break;
    }
  }
  return removezeros(bin.slice(0, j));
}
766575
function binaryTransfer(integer, binary) {
	binary = binary || 62;
	var stack = [];
	var num;
	var result = '';
	var sign = integer < 0 ? '-' : '';
	
	function table (num) {
		var t = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		return t[num];
	}
	
	integer = Math.abs(integer);
	
	while (integer >= binary) {
		num = integer % binary;
		integer = Math.floor(integer / binary);
		stack.push(table(num));
	}
	
	if (integer > 0) {
		stack.push(table(integer));
	}
	
	for (var i = stack.length - 1; i >= 0; i--) {
		result += stack[i];
	} 
	
	return sign + result;
}
433560
def to_bitarray(data, width=8):
    '''  '''
    if isinstance(data, list) or isinstance(data, bytearray):
        data = combine_hex(data)
    return [True if digit == '1' else False for digit in bin(data)[2:].zfill(width)]
295122
protected void fillArray(final short[] array) {
    int pos = 0;
    if (BufferUtil.isBackedBySimpleArray(bitmap)) {
      long[] b = bitmap.array();
      int base = 0;
      for (int k = 0; k < b.length; ++k) {
        long bitset = b[k];
        while (bitset != 0) {
          array[pos++] = (short) (base + numberOfTrailingZeros(bitset));
          bitset &= (bitset - 1);
        }
        base += 64;
      }

    } else {
      int len = this.bitmap.limit();
      int base = 0;
      for (int k = 0; k < len; ++k) {
        long bitset = bitmap.get(k);
        while (bitset != 0) {
          array[pos++] = (short) (base + numberOfLeadingZeros(bitset));
          bitset &= (bitset - 1);
        }
        base += 64;
      }
    }
  }
1187730
function add(out, a, b) {
  out[0] = a[0] + b[0];
  out[1] = a[1] + b[1];
  out[2] = a[2] + b[2];
  out[3] = a[3] + b[3];
  out[4] = a[4] + b[4];
  out[5] = a[5] + b[5];
  out[6] = a[6] + b[6];
  out[7] = a[7] + b[7];
  out[8] = a[8] + b[8];
  return out;
}
272601
public static int byteArrayToInt(byte[] b, int offset) {
        int value = 0;
        for (int i = 0; i < 4; i++) {
            int shift = (4 - 1 - i) * 8;
            value += (b[i + offset] & 0x000000FF) << shift;
}
        return value;
    }
681173
function bin_val() {
    var ret = this.seq(
        this.istringf('b'),
        bitChar,
        this.mightf(
            this.choicef(
                bit_string,
                bit_range)));
    var r3 = ret[3];
    if (r3) {
        if (typeof(r3) === "string") {
            // series of concatenated bit values
            return ret[2] + r3;
        } else {
            // range
            r3.setFirst(ret[2]);
            return r3;
        }
    }
    return ret[2];
}
445253
public static int fromBinary(boolean[] binary)
    {
        Check.notNull(binary);

        int number = 0;
        for (final boolean current : binary)
        {
            number = number << 1 | boolToInt(current);
        }
        return number;
    }
613546
function bitArrayToArray(bitArray) {
    let resultArray = [];
    for (let index = 0; index < bitArray.byteLength; index++) {
        let arrayByte = bitArray.readUInt8(index);
        // Skip bit operations if zero -> no bit is set
        if (arrayByte !== 0) {
            for (let bitIndex = 0; bitIndex < 8; bitIndex++) {
                if ((arrayByte & 0x01) === 0x01) {
                    resultArray.push(index * 8 + bitIndex);
                }
                arrayByte = arrayByte >>> 1;
            }
        }
    }
    return resultArray;
}
1348952
function addArr(arr1, arr2, shift = 0) {
  arr2.forEach((singlet, i) => {
    addNum(arr1, singlet, i + shift);
  });
}
2029
function placeBit(&$array, $NR, $NC, $r, $c, $p, $b) {
        if ($r < 0) {
            $r += $NR;
            $c += 4 - (($NR + 4) % 8);
        }
        if ($c < 0) {
            $c += $NC;
            $r += 4 - (($NC + 4) % 8);
        }

        $array[$r * $NC + $c] = ($p << 3) + $b;
    }
1084110
def add_ones(a):
    """"""
    arr = N.ones((a.shape[0],a.shape[1]+1))
    arr[:,:-1] = a
    return arr
148220
function onescomplement(bin){
  var len = bin.length;
  var onebin = new Array(len);
  for (var i=0; i<len; i++){onebin[i] = !bin[i];}
  return onebin;
}
19188
function count(arr) {
    var c = 0;
    for (var i = 0; i < arr.length; i++) {
        c += eightBits[arr[i] & 0xff] + eightBits[(arr[i] >> 8) & 0xff] + eightBits[(arr[i] >> 16) & 0xff] + eightBits[(arr[i] >> 24) & 0xff];
    }
    return c;
}
168576
function binarySearch (comparator, array, key) {
  var low = 0, high = array.length - 1, partition, compare;
  while (low <= high) {
    partition = Math.floor(low + (high - low) / 2);
    compare = comparator(key, array[partition]);
    if (compare < 0) high = partition - 1;
    else if (compare > 0) low = partition + 1;
    else return partition;
  }
  return low;
}