Java Code Examples for java.math.BigDecimal#ROUND_HALF_UP

The following examples show how to use java.math.BigDecimal#ROUND_HALF_UP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MallSetting.java    From java-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 设置精度
 * 
 * @param amount
 *            数值
 * @return 数值
 */
public BigDecimal setScale(BigDecimal amount) {
	if (amount == null) {
		return null;
	}
	int roundingMode;
	if (getPriceRoundType() == RoundType.roundUp) {
		roundingMode = BigDecimal.ROUND_UP;
	} else if (getPriceRoundType() == RoundType.roundDown) {
		roundingMode = BigDecimal.ROUND_DOWN;
	} else {
		roundingMode = BigDecimal.ROUND_HALF_UP;
	}
	return amount.setScale(getPriceScale(), roundingMode);
}
 
Example 2
Source File: ItemAvgFunction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs an unnamed function. Make sure to set a Name or function initialisation will fail.
 */
public ItemAvgFunction() {
  sum = new Sequence<BigDecimal>();
  itemCount = new Sequence<BigDecimal>();
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 3
Source File: TotalGroupSumQuotientFunction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs a new function.
 * <p/>
 * Initially the function has no name...be sure to assign one before using the function.
 */
public TotalGroupSumQuotientFunction() {
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
  dividendFunction = new TotalGroupSumFunction();
  divisorFunction = new TotalGroupSumFunction();
}
 
Example 4
Source File: ItemPercentageFunction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a new ItemPercentageFunction.
 */
public ItemPercentageFunction() {
  totalSumFunction = new TotalGroupSumFunction();
  totalSumFunction.setName( "total" );
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
  scaleToHundred = true;
}
 
Example 5
Source File: JdkCurrencyProvider.java    From objectlabkit with Apache License 2.0 4 votes vote down vote up
@Override
public int getRounding(String currencyCode) {
    return "JPY".equalsIgnoreCase(currencyCode) ? BigDecimal.ROUND_DOWN : BigDecimal.ROUND_HALF_UP;
}
 
Example 6
Source File: ColumnDivisionExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Default constructor.
 */
public ColumnDivisionExpression() {
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 7
Source File: ColumnAverageExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Default Constructor.
 */
public ColumnAverageExpression() {
  this.returnInfinity = true; // for backward compatiblity.
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 8
Source File: AverageExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates a new expression. The fields used by the expression are defined using properties named '0', '1', ... 'N'.
 * These fields should contain {@link Number} instances.
 */
public AverageExpression() {
  this.fieldList = new ArrayList();
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 9
Source File: PercentageExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Constructs a new function.
 * <P>
 * Initially the function has no name...be sure to assign one before using the function.
 */
public PercentageExpression() {
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}