Used to convert a blz or an account number to an array of ints, one
array element per digit.
323675
private static int[] string2Ints(String st, int target_length) {
        int[] numbers = new int[target_length];
        int st_len = st.length();
        char ch;

        for (int i = 0; i < st_len; i++) {
            ch = st.charAt(i);
            numbers[target_length - st_len + i] = ch - '0';
        }

        return numbers;
    }
888086
def _convert_1bit_array_to_byte_array(arr):
    
    # Padding if necessary
    while len(arr) < 8 or len(arr) % 8:
        arr.append(0)

    arr = _np.array(arr, dtype='uint8')
    bit_arr = []
    idx = 0
    # Iterate and combine 8-bits into a uint8
    for arr_idx in range(int(len(arr) / 8)):
        bit_arr.append(((arr[idx] << 7) & (1 << 7)) |
                        ((arr[idx+1] << 6) & (1 << 6)) |
                        ((arr[idx+2] << 5) & (1 << 5)) |
                        ((arr[idx+3] << 4) & (1 << 4)) |
                        ((arr[idx+4] << 3) & (1 << 3)) |
                        ((arr[idx+5] << 2) & (1 << 2)) |
                        ((arr[idx+6] << 1) & (1 << 1)) |
                        ((arr[idx+7] << 0) & (1 << 0))
                        )
        idx += 8
    return _np.array(bit_arr, dtype='uint8')
1167867
int[] toIntArray() {
		int[] out = new int[size()];
		int a = 0, b = out.length;
		for (int i = -1; (i = ints.nextSetBit(i + 1)) >= 0;) {
			int n = decode(i);
			if (n < 0) {
				out[a++] = n;
			} else {
				out[--b] = n;
			}
		}

		//if it contains  -3, -1, 0, 1, 2, 4
		//then out will be -1, -3, 4, 2, 1, 0
		reverse(out, 0, a);
		reverse(out, a, out.length);

		return out;
	}
1088320
def _int_to_binary(integer, size=None):
    
    binary_list = map(int, format(integer, 'b'))

    if size is None:
        return binary_list
    else:
        if len(binary_list) > size:
            # Too long, take only last n
            return binary_list[len(binary_list)-size:]
        elif size > len(binary_list):
            # Too short, pad
            return [0]*(size-len(binary_list)) + binary_list
        else:
            # Just right
            return binary_list
95952
private int[] maxIntegerDigits(double[][] values) {
    int[] digits = new int[values[0].length];
    for(int j = 0; j < values[0].length; j++) {
      for(double[] value : values) {
        digits[j] = Math.max(digits[j], integerDigits(value[j]));
      }
    }
    return digits;
  }
197104
private static int intFromBigEndian(final byte[] array, final int index) {
        return ((array[index     ] & 0xff) << 24) |
                ((array[index + 1] & 0xff) << 16) |
                ((array[index + 2] & 0xff) <<  8) |
                ((array[index + 3] & 0xff)      );
    }
97348
def sub_integer(integer, bit_range)
      bit_range = bit_range..bit_range if bit_range.kind_of?(Integer)
      num = 0
      bit_range.reverse_each do |i|
        num = num << 1
        num += integer[i]
      end
      return num
    end
506129
function toHex(bignum) {
      var tmp0 = bignum[0] < 0 ? (bignum[0]>>>0) : bignum[0];
      var tmp1 = bignum[1] < 0 ? (bignum[1]>>>0) : bignum[1];
      return tmp0.toString(16) + tmp1.toString(16);
    }
699352
public void parseNumbers() {
        for (int i = '0'; i <= '9'; i++) {
            tokenTypes[i] |= TOKEN_DIGIT;
        }
        tokenTypes['.'] |= TOKEN_DIGIT;
        tokenTypes['-'] |= TOKEN_DIGIT;
    }
1359522
private static int[] calculate(byte[] data) {
    int A = 0x67452301;
    int B = 0xEFCDAB89;
    int C = 0x98BADCFE;
    int D = 0x10325476;
    int E = 0xC3D2E1F0;

    int[] W = new int[80]; // working buffer
    int len = data.length;
    int off = 0;
    int   X, i, n = len/4;

    boolean done = false;
    boolean padded = false;

    while( !done ) {
      // Fill W array
      for(i=0; (i<16) && (n > 0); n--, off+=4)
        W[i++] = (data[off+3] & 0xFF) | ((data[off+2] & 0xFF) << 8) |
          ((data[off+1] & 0xFF) << 16) | ((data[off] & 0xFF) << 24);

      if (i < 16) {             // pad
        if( !padded ) {         // first time past end of data
          X=len%4;
          int pad1 = 0;
          for (int j = 0; j < X; ++j) {
            pad1 |= ((int) (data[off + j] & 0xFF)) << (24 - 8 * j);
          }
          W[i++] = pad1 | (1 << (31 - X * 8));
//            W[i++] = (X!=0)?(((int)msbf(data,off,X)<<((4-X)*8))|(1<<(31-X*8))):(1<<31);
          if (i==15) W[15]=0;   // 64 bit length of data as bits can't fit
          padded = true;        // don't pad again if there is another iteration
        }
        if (i <= 14) {          // last iteration
          while( i<14 ) W[i++] = 0;
          // bit count = len*8
          W[14] = len >>> 29;
          W[15] = len << 3;
          done = true;
        }
        i = 16;
      }

      do {
        W[i] = ((X = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]) << 1) | (X >>> 31);
      } while(++i<80);

      // Transform
      int A0 = A;
      int B0 = B;
      int C0 = C;
      int D0 = D;
      int E0 = E;
      i = 0;
      do { X=((A<<5)|(A>>>27))+((B&C)|(~B&D))+E+W[i]+0x5A827999;
      E=D;D=C;C=(B<<30)|(B>>>2);B=A;A=X; } while(++i<20);
      do { X=((A<<5)|(A>>>27))+(B^C^D)+E+W[i]+0x6ED9EBA1;
      E=D;D=C;C=(B<<30)|(B>>>2);B=A;A=X; } while(++i<40);
      do { X=((A<<5)|(A>>>27))+((B&C)|(B&D)|(C&D))+E+W[i]+0x8F1BBCDC;
      E=D;D=C;C=(B<<30)|(B>>>2);B=A;A=X; } while(++i<60);
      do { X=((A<<5)|(A>>>27))+(B^C^D)+E+W[i]+0xCA62C1D6;
      E=D;D=C;C=(B<<30)|(B>>>2);B=A;A=X; } while(++i<80);
      A += A0;
      B += B0;
      C += C0;
      D += D0;
      E += E0;
    }

    int[] result = {A, B, C, D, E};
    return result;
  }
620514
private int toInt(byte[] data)
    {
        if (data == null || data.length != 4)
            return 0x0;

        return (int) ( // NOTE: type cast not necessary for int
        (0xff & data[0]) << 24 | (0xff & data[1]) << 16 | (0xff & data[2]) << 8 | (0xff & data[3]) << 0);
    }
740854
public int[] readInts (int length) throws KryoException {
		int[] array = new int[length];
		if (optional(length << 2) == length << 2) {
			byte[] buffer = this.buffer;
			int p = this.position;
			for (int i = 0; i < length; i++, p += 4) {
				array[i] = buffer[p] & 0xFF //
					| (buffer[p + 1] & 0xFF) << 8 //
					| (buffer[p + 2] & 0xFF) << 16 //
					| (buffer[p + 3] & 0xFF) << 24;
			}
			position = p;
		} else {
			for (int i = 0; i < length; i++)
				array[i] = readInt();
		}
		return array;
	}
1163745
static int[] toArray(long set) {

        int[] vertices = new int[Long.bitCount(set)];
        int i = 0;

        // fill the cyclic vertices with the bits that have been set
        for (int v = 0; i < vertices.length; v++) {
            if (isBitSet(set, v)) vertices[i++] = v;
        }

        return vertices;
    }
1341955
function BigNumber(initialNumber) {
        var index;

        if (!(this instanceof BigNumber)) {
            return new BigNumber(initialNumber);
        }

        this.number = [];
        this.sign = 1;
        this.rest = 0;

        // The initial number can be an array, string, number of another big number
        // e.g. array     : [3,2,1], ['+',3,2,1], ['-',3,2,1]
        //      number    : 312
        //      string    : '321', '+321', -321'
        //      BigNumber : BigNumber(321)
        // Every character except the first must be a digit

        if (!isValidType(initialNumber)) {
            this.number = errors['invalid'];
            return;
        }

        if (isArray(initialNumber)) {
            if (initialNumber.length && initialNumber[0] === '-' || initialNumber[0] === '+') {
                this.sign = initialNumber[0] === '+' ? 1 : -1;
                initialNumber.shift(0);
            }
            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(initialNumber[index]))
                    return;
            }
        } else {
            initialNumber = initialNumber.toString();
            if (initialNumber.charAt(0) === '-' || initialNumber.charAt(0) === '+') {
                this.sign = initialNumber.charAt(0) === '+' ? 1 : -1;
                initialNumber = initialNumber.substring(1);
            }

            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(parseInt(initialNumber.charAt(index), 10))) {
                    return;
                }
            }
        }
    }
1250633
function(totalDigits, digits) {
			var total    = 0;
			var newArray = [];
			
			$.each(digits, function(i, digit) {
				if(i < totalDigits) {
					total += parseInt(digits[i], 10);
				}
				else {
					newArray.push(digits[i]);
				}
			});
			
			if(total === 0) {
				return newArray;
			}
			
			return digits;
		}
1203284
def bitlist_to_int(bitlist):
    

    ret = 0
    for b in bitlist:
        ret = (ret << 1) | (int(b) & 1)
    return ret
264687
function (intsList) {
    var ret = []
    for (var k in intsList) {
      ret.push(this.hexConvert(intsList[k]))
    }
    return ret
  }