Java BigInteger Calculate copyOf(BigInteger[] data, int newLength)

Here you can find the source of copyOf(BigInteger[] data, int newLength)

Description

copy Of

License

Apache License

Declaration

public static BigInteger[] copyOf(BigInteger[] data, int newLength) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

public class Main {
    public static byte[] copyOf(byte[] data, int newLength) {
        byte[] tmp = new byte[newLength];

        if (newLength < data.length) {
            System.arraycopy(data, 0, tmp, 0, newLength);
        } else {//from  w  w w  .ja va  2 s  . c o m
            System.arraycopy(data, 0, tmp, 0, data.length);
        }

        return tmp;
    }

    public static char[] copyOf(char[] data, int newLength) {
        char[] tmp = new char[newLength];

        if (newLength < data.length) {
            System.arraycopy(data, 0, tmp, 0, newLength);
        } else {
            System.arraycopy(data, 0, tmp, 0, data.length);
        }

        return tmp;
    }

    public static int[] copyOf(int[] data, int newLength) {
        int[] tmp = new int[newLength];

        if (newLength < data.length) {
            System.arraycopy(data, 0, tmp, 0, newLength);
        } else {
            System.arraycopy(data, 0, tmp, 0, data.length);
        }

        return tmp;
    }

    public static long[] copyOf(long[] data, int newLength) {
        long[] tmp = new long[newLength];

        if (newLength < data.length) {
            System.arraycopy(data, 0, tmp, 0, newLength);
        } else {
            System.arraycopy(data, 0, tmp, 0, data.length);
        }

        return tmp;
    }

    public static BigInteger[] copyOf(BigInteger[] data, int newLength) {
        BigInteger[] tmp = new BigInteger[newLength];

        if (newLength < data.length) {
            System.arraycopy(data, 0, tmp, 0, newLength);
        } else {
            System.arraycopy(data, 0, tmp, 0, data.length);
        }

        return tmp;
    }
}

Related

  1. castToBigInteger(Object val)
  2. chop(BigInteger in, int bits)
  3. clip(BigInteger bi, int numberOfBytes)
  4. clone(BigInteger[] data)
  5. copy_into_byte_array(BigInteger bi, byte[] a)
  6. copyOfRange(BigInteger[] data, int from, int to)
  7. createUnsignedBigInteger(byte[] data)
  8. createUUID(int version, String gtin, BigInteger phar)
  9. cryptRSA(byte[] data, BigInteger exponent, BigInteger modulus)