Returns a Little-Endian byte array extracted from the given int.
@param v the given int
@param arr a given array of 4 bytes that will be returned with the data
@return a Little-Endian byte array extracted from the given int.
549732
public static byte[] intToBytes(int v, final byte[] arr) {
    for (int i = 0; i < 4; i++) {
      arr[i] = (byte) (v & 0XFF);
      v >>>= 8;
    }
    return arr;
  }
412778
public static boolean wholeArrayDimension(int... arr) {
        return arr == null || arr.length == 0 || (arr.length == 1 && arr[0] == Integer.MAX_VALUE);
    }
851016
static int writeVInt(byte[] array, int offset, int value) {
    assert value >= 0 : "Can't v-code negative ints.";

    while (value > 0x7F) {
      array[offset++] = (byte) (0x80 | (value & 0x7F));
      value >>= 7;
    }
    array[offset++] = (byte) value;

    return offset;
  }
217984
static int getInt(final byte[] arr, final long off) throws IOException {
        final int ioff = (int) off;
        if (ioff < 0 || ioff > arr.length - 4) {
            throw new IndexOutOfBoundsException();
        }
        return ((arr[ioff + 3] & 0xff) << 24) //
                | ((arr[ioff + 2] & 0xff) << 16) //
                | ((arr[ioff + 1] & 0xff) << 8) //
                | (arr[ioff] & 0xff);
    }
160953
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public byte[] toByteArrayOfSpecifiedEndianness(boolean bigEndian) {
        byte[] copy = Arrays.copyOf(mValue, mValue.length);

        if (!bigEndian) {
            reverseArray(copy);
        }

        return copy;
    }
563487
function UniArrayToUTF8(arr) {
    var count = 0;

    for (var ix=0; ix<arr.length; ix++) {
        var val = arr[ix];
        if (val < 0x80) {
            count += 1;
        }
        else if (val < 0x800) {
            count += 2;
        }
        else if (val < 0x10000) {
            count += 3;
        }
        else if (val < 0x200000) {
            count += 4;
        }
        else {
            count += 1;
        }
    }

    if (count == arr.length)
        return arr;

    var res = [];
    for (var ix=0; ix<arr.length; ix++) {
        var val = arr[ix];
        if (val < 0x80) {
            res.push(val);
        }
        else if (val < 0x800) {
            res.push(0xC0 | ((val & 0x7C0) >> 6));
            res.push(0x80 |  (val & 0x03F)     );
        }
        else if (val < 0x10000) {
            res.push(0xE0 | ((val & 0xF000) >> 12));
            res.push(0x80 | ((val & 0x0FC0) >>  6));
            res.push(0x80 |  (val & 0x003F)      );
        }
        else if (val < 0x200000) {
            res.push(0xF0 | ((val & 0x1C0000) >> 18));
            res.push(0x80 | ((val & 0x03F000) >> 12));
            res.push(0x80 | ((val & 0x000FC0) >>  6));
            res.push(0x80 |  (val & 0x00003F)      );
        }
        else {
            res.push(63);  // '?'
        }
    }

    return res;
}
829150
static byte[] convertBoolArrayToByteArray(boolean[] boolArr) {
    byte[] byteArr = new byte[(boolArr.length + 7) / 8];
    for (int i = 0; i < byteArr.length; i++) {
      byteArr[i] = readByte(boolArr, 8 * i);
    }
    return byteArr;
  }
129869
public static ByteBuffer toByteBuffer(INDArray arr) {
        //subset and get rid of 1 off non 1 element wise stride cases
        if (arr.isView())
            arr = arr.dup();
        if (!arr.isCompressed()) {
            ByteBuffer b3 = ByteBuffer.allocateDirect(byteBufferSizeFor(arr)).order(ByteOrder.nativeOrder());
            doByteBufferPutUnCompressed(arr, b3, true);
            return b3;
        }
        //compressed array
        else {
            ByteBuffer b3 = ByteBuffer.allocateDirect(byteBufferSizeFor(arr)).order(ByteOrder.nativeOrder());
            doByteBufferPutCompressed(arr, b3, true);
            return b3;
        }

    }
521940
public static INDArray toOffsetZero(INDArray arr) {
        if (arr.offset() < 1 && arr.data().length() == arr.length())
            if (arr.ordering() == 'f' && arr.stride(-1) != 1
                    || arr.ordering() == 'c' && arr.stride(0) != 1)
                return arr;

        if (arr.isRowVector()) {
            INDArray ret = Nd4j.create(arr.shape());
            for (int i = 0; i < ret.length(); i++)
                ret.putScalar(i, arr.getDouble(i));
            return ret;
        }

        INDArray ret = Nd4j.create(arr.shape(), arr.ordering());
        ret.assign(arr);
        return ret;
    }
1322732
public static float byteArrayToFloatLE( byte[] data ) {
        ByteBuffer buffer = ByteBuffer.wrap(data);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        return buffer.getFloat();
    }
1261993
public static int toInt(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return (b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8) |
					((b[off + 2] & 0xFF) << 16) | ((b[off + 3] & 0xFF) << 24);
		}
		return ((b[off] & 0xFF) << 24) | ((b[off + 1] & 0xFF) << 16) |
				((b[off + 2] & 0xFF) << 8) | (b[off + 3] & 0xFF);
	}
62745
function (arr) {
		var res = [];
		for (var i = 0; i < arr.length; i++) {
			res[i] = this._v(arr[i]);
		}
		return res;
	}
1352784
public static int aton(final byte[] addr)
	{
		int address = addr[3] & 0xFF;
		address |= ((addr[2] << 8) & 0xFF00);
		address |= ((addr[1] << 16) & 0xFF0000);
		address |= ((addr[0] << 24) & 0xFF000000);

		return address;
	}
788781
private static int extractInt(byte[] arr, int offset) {
        return ((arr[offset] & 0xFF) << 24) | ((arr[offset + 1] & 0xFF) << 16) | ((arr[offset + 2] & 0xFF) << 8)
                | (arr[offset + 3] & 0xFF);
    }
599379
@Override
	byte[] toByteArray(final ByteArrayOutputStream os)
	{
		os.write(channelid);
		os.write(0);
		final byte[] buf = endpt.toByteArray();
		os.write(buf, 0, buf.length);
		return os.toByteArray();
	}
1317972
public static IntBuffer toBuffer(int... arr) {
        ByteBuffer directBuffer = ByteBuffer.allocateDirect(arr.length * 4).order(ByteOrder.nativeOrder());
        IntBuffer buffer = directBuffer.asIntBuffer();
        for (int i = 0; i < arr.length; i++)
            buffer.put(i, arr[i]);

        return buffer;
    }
878288
public static byte[] longToRegisters(long v) {
        byte[] registers = new byte[8];
        registers[0] = (byte)(0xff & (v >> 56));
        registers[1] = (byte)(0xff & (v >> 48));
        registers[2] = (byte)(0xff & (v >> 40));
        registers[3] = (byte)(0xff & (v >> 32));
        registers[4] = (byte)(0xff & (v >> 24));
        registers[5] = (byte)(0xff & (v >> 16));
        registers[6] = (byte)(0xff & (v >> 8));
        registers[7] = (byte)(0xff & v);
        return registers;
    }