Converts a BigInteger array into an integer array, reducing all BigIntegers mod q. - Java java.math

Java examples for java.math:BigInteger

Description

Converts a BigInteger array into an integer array, reducing all BigIntegers mod q.

Demo Code


//package com.java2s;
import java.math.BigInteger;

public class Main {
    /**/*www.  j  a v a  2  s  .  c o m*/
     * Converts a BigInteger array into an integer array, reducing all
     * BigIntegers mod q.
     * 
     * @param q
     *            - the modulus
     * @param input
     *            - the BigInteger array
     * @return the integer array
     */
    public static int[] toIntArrayModQ(int q, BigInteger[] input) {
        BigInteger bq = BigInteger.valueOf(q);
        int[] result = new int[input.length];
        for (int i = 0; i < input.length; i++) {
            result[i] = input[i].mod(bq).intValue();
        }
        return result;
    }
}

Related Tutorials