Here you can find the source of incRatio(BigDecimal o1, BigDecimal o2)
Parameter | Description |
---|---|
o1 | <code>java.lang.Integer</code> |
o2 | <code>java.lang.Integer</code> |
public static BigDecimal incRatio(BigDecimal o1, BigDecimal o2)
//package com.java2s; /*/*w w w. ja v a 2s . 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 { /** * calc a ratio increase between two Integer; * * @param o1 <code>java.lang.Integer</code> * @param o2 <code>java.lang.Integer</code> * @return (o1-o2)/o2 */ public static BigDecimal incRatio(Integer o1, Integer o2) { double d1, d2; if (o1 == null && o2 == null) { return new BigDecimal(0); } if (o2 == null || o2.intValue() == 0) { return new BigDecimal(100); } if (o1 != null) { d1 = o1.doubleValue(); } else { d1 = 0; } d2 = o2.doubleValue(); return new BigDecimal((d1 - d2) / d2 * 100); } /** * calc a increase ratio between two BigDecimal; * * @param o1 <code>java.lang.Integer</code> * @param o2 <code>java.lang.Integer</code> * @return (o1-o2)/o2 */ public static BigDecimal incRatio(BigDecimal o1, BigDecimal o2) { double d1, d2; if (o1 == null && o2 == null) { return new BigDecimal(0); } if (o2 == null || o2.intValue() == 0) { return new BigDecimal(100); } if (o1 != null) { d1 = o1.doubleValue(); } else { d1 = 0; } d2 = o2.doubleValue(); return new BigDecimal((d1 - d2) / d2 * 100); } }