Here you can find the source of compareTo(final BigDecimal b0, final BigDecimal b1)
Parameter | Description |
---|---|
b0 | the first BigDecimal . |
b1 | the second BigDecimal . |
public static int compareTo(final BigDecimal b0, final BigDecimal b1)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013, 2014, 2015 QPark Consulting S.a r.l. * /*from w w w . j a v a 2s . c om*/ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0. * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html. ******************************************************************************/ import java.math.BigDecimal; public class Main { /** * Null safe compareTo of two {@link BigDecimal}s. * * @param b0 * the first {@link BigDecimal}. * @param b1 * the second {@link BigDecimal}. * @return equal, more little or greater. * @see BigDecimal#compareTo(Object) */ public static int compareTo(final BigDecimal b0, final BigDecimal b1) { if (b0 == b1) { return 0; } else if (b0 == null) { return 1; } else if (b1 == null) { return -1; } else { return b0.compareTo(b1); } } /** * Null safe compareTo of two {@link BigDecimal}s. * * @param d0 * the first {@link BigDecimal}. * @param d1 * the second {@link BigDecimal}. * @return equal, more little or greater. * @see BigDecimal#compareTo(Object) */ public static int compareTo(final Double d0, final Double d1) { if (d0 == d1) { return 0; } else if (d0 == null) { return 1; } else if (d1 == null) { return -1; } else { return d0.compareTo(d1); } } }