Java BigInteger Calculate getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)

Here you can find the source of getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)

Description

This method generates all integer numbers between the given range

License

Open Source License

Parameter

Parameter Description
minValue The minimum value of the range
maxValue The maximum value of the range

Return

A list which contains all numbers between the range

Declaration

private static List<BigInteger> getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Main {
    /**/*from w w w  .j  a va 2  s.  co  m*/
     * This method generates all integer numbers between the given range
     * 
     * @param minValue
     *            The minimum value of the range
     * @param maxValue
     *            The maximum value of the range
     * @return A list which contains all numbers between the range
     */
    private static List<BigInteger> getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue) {
        List<BigInteger> numbers;
        if (maxValue.longValue() > Integer.MAX_VALUE) {
            numbers = new LinkedList<>();
        } else {
            numbers = new ArrayList<>();
        }
        BigInteger auxiliarNumber = minValue;
        for (; auxiliarNumber.compareTo(maxValue) < 1; auxiliarNumber = auxiliarNumber.add(BigInteger.ONE)) {
            numbers.add(auxiliarNumber);
        }
        return numbers;
    }
}

Related

  1. getNafWeight(BigInteger k)
  2. getNatRouterIdFromMetadata(BigInteger metadata)
  3. getNetAddress(BigInteger ip, BigInteger netmask)
  4. getNextLexicographicalPermutation(BigInteger v)
  5. getNRightmostBits(final BigInteger in, final int n)
  6. getPrivateKey(BigInteger ran, BigInteger publicKey)
  7. getPrivateKeyBytes(BigInteger privateKey)
  8. getQosFlowId(short tableId, BigInteger dpId, int lportTag)
  9. getRadixNumberInString(BigInteger integerNumber, int radix)