Here you can find the source of min(BigInteger a, BigInteger b)
Parameter | Description |
---|---|
a | Can be null |
b | Can be null |
public static BigInteger min(BigInteger a, BigInteger b)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; import java.util.Collection; public class Main { /**//from w ww. j a v a 2s . co m * * @param xs * Can contain nulls -- which are ignored * @return this will be a member of the xs */ public static <N extends Number> N min(Collection<N> xs) { assert !xs.isEmpty(); double min = Double.POSITIVE_INFINITY; N minn = null; for (N number : xs) { // skip null! if (number == null) { continue; } double x = number.doubleValue(); if (x < min) { min = x; minn = number; } } return minn; } /** * @param values * Must not be zero-length or null * @return min of values (remember that -100 beats 1 - use min + abs if you * want the smallest number) */ public static double min(double... values) { double min = values[0]; for (double i : values) { if (i < min) { min = i; } } return min; } /** * Since Math.max() doesn't handle BigInteger * * @param a Can be null * @param b Can be null * @return the max of a,b, or null if both are null */ public static BigInteger min(BigInteger a, BigInteger b) { if (a == null) return b; if (b == null) return a; int c = a.compareTo(b); return c > 0 ? b : a; } }