Here you can find the source of min(BigDecimal b1, BigDecimal b2)
Parameter | Description |
---|---|
b1 | <code>java.math.BigDecimal</code> |
b2 | <code>java.math.BigDecimal</code> |
java.math.BigDecimal
public static BigDecimal min(BigDecimal b1, BigDecimal b2)
//package com.java2s; /*// w w w. j a v a 2 s . c o m * File: $RCSfile$ * * Copyright (c) 2005 Wincor Nixdorf International GmbH, * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany * All Rights Reserved. * * This software is the confidential and proprietary information * of Wincor Nixdorf ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with Wincor Nixdorf. */ import java.math.BigDecimal; public class Main { public static final BigDecimal ZERO = new BigDecimal((double) 0); /** * Return min value of @param b1 and @param b2 * * @param b1 <code>java.math.BigDecimal</code> * @param b2 <code>java.math.BigDecimal</code> * @return <code>java.math.BigDecimal</code> */ public static BigDecimal min(BigDecimal b1, BigDecimal b2) { if (b1 == null && b2 == null) { return null; } if (b1 == null) { b1 = ZERO; } if (b2 == null) { b2 = ZERO; } if (b1.compareTo(b2) <= 0) { return b1; } return b2; } /** * Compare to b1 with b2 * * @param b1 <code>java.math.BigDecimal</code> * @param b2 <code>java.math.BigDecimal</code> * @return if b1 and b2 ==null return 0, else @see java.math.BigDecimal#compareTo */ public static int compareTo(BigDecimal b1, BigDecimal b2) { if (b1 == null && b2 == null) { return 0; } if (b1 == null) { b1 = ZERO; } if (b2 == null) { b2 = ZERO; } return b1.compareTo(b2); } }