Here you can find the source of min(final BigDecimal bd1, final BigDecimal bd2)
Parameter | Description |
---|---|
bd1 | First value. |
bd2 | Second value. |
public static BigDecimal min(final BigDecimal bd1, final BigDecimal bd2)
//package com.java2s; /* Copyright (c) 2011-2014 Pushing Inertia * All rights reserved. http://pushinginertia.com * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * 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./*from w w w. java2 s.co m*/ */ import java.math.BigDecimal; public class Main { /** * Selects the lower of two BigDecimals, preferring the non-null value if one is null. * @param bd1 First value. * @param bd2 Second value. * @return Min of the two values or the non-null reference or null if both inputs are null. */ public static BigDecimal min(final BigDecimal bd1, final BigDecimal bd2) { if (bd1 == null) { return bd2; } if (bd2 == null) { return bd1; } if (bd1.compareTo(bd2) < 0) { return bd1; } return bd2; } }