Here you can find the source of maximum(BigDecimal... values)
Parameter | Description |
---|---|
values | Array of values. |
public static BigDecimal maximum(BigDecimal... values)
//package com.java2s; /**//from w w w. j av a 2s .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 maximum(long... values) { int len = values.length; long current = values[0]; for (int i = 1; i < len; i++) { current = Math.max(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 maximum(double... values) { int len = values.length; double current = values[0]; for (int i = 1; i < len; i++) { current = Math.max(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 maximum(BigInteger... values) { int len = values.length; if (len == 1) { if (values[0] == null) { throw new IllegalArgumentException("Cannot passed null BigInteger entry to maximum()"); } 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 maximum()"); } current = values[i].max(current); } return current; } /** * Calculate the maximum value from an array of values. * * @param values Array of values. * @return maximum value of the provided set. */ public static BigDecimal maximum(BigDecimal... values) { int len = values.length; if (len == 1) { if (values[0] == null) { throw new IllegalArgumentException("Cannot passed null BigDecimal entry to maximum()"); } 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 maximum()"); } current = values[i].max(current); } return current; } }