Here you can find the source of minimum(BigDecimal... values)
Parameter | Description |
---|---|
values | Array of values. |
public static BigDecimal minimum(BigDecimal... values)
//package com.java2s; /**//w w w . j ava 2 s . co m * Useful Math utilities * * @author John DeRegnaucourt (john@cedarsoftware.com) * <br> * Copyright (c) Cedar Software LLC * <br><br> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <br><br> * http://www.apache.org/licenses/LICENSE-2.0 * <br><br> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.math.BigDecimal; import java.math.BigInteger; public class Main { /** * Calculate the minimum value from an array of values. * * @param values Array of values. * @return minimum value of the provided set. */ public static long minimum(long... values) { int len = values.length; long current = values[0]; for (int i = 1; i < len; i++) { current = Math.min(values[i], current); } return current; } /** * Calculate the minimum value from an array of values. * * @param values Array of values. * @return minimum value of the provided set. */ public static double minimum(double... values) { int len = values.length; double current = values[0]; for (int i = 1; i < len; i++) { current = Math.min(values[i], current); } return current; } /** * Calculate the minimum value from an array of values. * * @param values Array of values. * @return minimum value of the provided set. */ public static BigInteger minimum(BigInteger... values) { int len = values.length; if (len == 1) { if (values[0] == null) { throw new IllegalArgumentException("Cannot passed null BigInteger entry to minimum()"); } return values[0]; } BigInteger current = values[0]; for (int i = 1; i < len; i++) { if (values[i] == null) { throw new IllegalArgumentException("Cannot passed null BigInteger entry to minimum()"); } current = values[i].min(current); } return current; } /** * Calculate the minimum value from an array of values. * * @param values Array of values. * @return minimum value of the provided set. */ public static BigDecimal minimum(BigDecimal... values) { int len = values.length; if (len == 1) { if (values[0] == null) { throw new IllegalArgumentException("Cannot passed null BigDecimal entry to minimum()"); } return values[0]; } BigDecimal current = values[0]; for (int i = 1; i < len; i++) { if (values[i] == null) { throw new IllegalArgumentException("Cannot passed null BigDecimal entry to minimum()"); } current = values[i].min(current); } return current; } }