Java BigInteger Calculate equals(BigInteger[] a, BigInteger[] b)

Here you can find the source of equals(BigInteger[] a, BigInteger[] b)

Description

Checks if two BigInteger arrays contain the same entries

License

Open Source License

Parameter

Parameter Description
a first BigInteger array
b second BigInteger array

Return

true or false

Declaration

public static boolean equals(BigInteger[] a, BigInteger[] b) 

Method Source Code

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

public class Main {
    /**/*  w  w w .  j  a v  a 2  s  . com*/
     * Checks if two BigInteger arrays contain the same entries
     *
     * @param a first BigInteger array
     * @param b second BigInteger array
     * @return true or false
     */
    public static boolean equals(BigInteger[] a, BigInteger[] b) {
        int flag = 0;

        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; i++) {
            // avoid branches here!
            // problem: compareTo on BigIntegers is not
            // guaranteed constant-time!
            flag |= a[i].compareTo(b[i]);
        }
        return flag == 0;
    }
}

Related

  1. encodeMPI(BigInteger value, boolean includeLength)
  2. encodeToBase62(BigInteger num)
  3. encodeToString(final BigInteger input)
  4. encodeURL(BigInteger id)
  5. equal(BigInteger int1, BigInteger int2)
  6. extractBoolean(BigInteger bi, int index)
  7. extractFloat(BigInteger bi, int start, int end, int decimal)
  8. extractInt(BigInteger bi, int start, int end)
  9. fill(BigInteger[] array, BigInteger value)