java.math.BigDecimal.multiply()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(600)

本文整理了Java中java.math.BigDecimal.multiply()方法的一些代码示例,展示了BigDecimal.multiply()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigDecimal.multiply()方法的具体详情如下:
包路径:java.math.BigDecimal
类名称:BigDecimal
方法名:multiply

BigDecimal.multiply介绍

[英]Returns a new BigDecimal whose value is this . The scale of the result is the sum of the scales of the two arguments.
[中]返回一个新的BigDecimal,其值为。结果的规模是两个参数规模的总和。

代码示例

代码示例来源:origin: prestodb/presto

public static int extractNanosecondDecimal(BigDecimal value, long integer)
  {
    // !!! 14-Mar-2016, tatu: Somewhat inefficient; should replace with functionally
    //   equivalent code that just subtracts integral part? (or, measure and show
    //   there's no difference and do nothing... )
    return value.subtract(new BigDecimal(integer)).multiply(ONE_BILLION).intValue();
  }
}

代码示例来源:origin: knowm/XChange

public BigDecimal calcAsk() {
 return ask.add(BASIS_POINT_MULTIPLIER.multiply(askBP));
}

代码示例来源:origin: stackoverflow.com

public class Payment
{
  BigDecimal itemCost  = BigDecimal.ZERO;
  BigDecimal totalCost = BigDecimal.ZERO;

  public BigDecimal calculateCost(int itemQuantity, BigDecimal itemPrice)
  {
    itemCost  = itemPrice.multiply(new BigDecimal(itemQuantity));
    totalCost = totalCost.add(itemCost);
    return totalCost;
  }
}

代码示例来源:origin: openhab/openhab1-addons

private PercentType byteToPercentType(int byteValue) {
  BigDecimal percentValue = new BigDecimal(byteValue).multiply(BigDecimal.valueOf(100))
      .divide(BigDecimal.valueOf(255), 2, BigDecimal.ROUND_HALF_UP);
  return new PercentType(percentValue);
}

代码示例来源:origin: stackoverflow.com

BigDecimal product=new BigDecimal(1);
for(int i=10;i<99;i++){
  product=product.multiply(new BigDecimal(i));
}
System.out.println(product);

代码示例来源:origin: stackoverflow.com

BigDecimal bigDecimal = BigDecimal.valueOf(100000.0)
          .multiply(BigDecimal.valueOf(100d))
          .stripTrailingZeros();
System.out.println("plain      : " + bigDecimal.toPlainString());
System.out.println("scientific : " + bigDecimal.toEngineeringString());

代码示例来源:origin: sk.seges.acris/acris-crypto

public static void main(String[] args) {
    System.out.println(getSHAHexDigest("deadda1"));
    BigDecimal basePrice = new BigDecimal(100);
    Double priceConditionValue = -40d;
    basePrice = basePrice.subtract(basePrice.multiply(BigDecimal.valueOf(priceConditionValue/100)));
        
    System.out.println(basePrice);
   }
}

代码示例来源:origin: knowm/XChange

public BigDecimal calculateFeeBtc() {
 return roundUp(amount.multiply(new BigDecimal(.5))).divide(new BigDecimal(100.));
}

代码示例来源:origin: hibernate/hibernate-orm

public IntegralDataTypeHolder multiplyBy(long factor) {
  checkInitialized();
  value = value.multiply( BigDecimal.valueOf( factor ) );
  return this;
}

代码示例来源:origin: vipshop/vjtools

/**
 * 人民币金额单位转换,元转换成分,例如:1 => 100
 */
public static BigDecimal yuan2fen(String y) {
  return new BigDecimal(Math.round(new BigDecimal(y).multiply(new BigDecimal(100)).doubleValue()));
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public BigDecimal getBigNumber( Object object ) throws KettleValueException {
 Timestamp timestamp = getTimestamp( object );
 if ( timestamp == null ) {
  return null;
 }
 BigDecimal nanos =
   BigDecimal.valueOf( timestamp.getTime() ).multiply( BigDecimal.valueOf( 1000000000L ) ).add(
     BigDecimal.valueOf( timestamp.getNanos() ) );
 return nanos;
}

代码示例来源:origin: stackoverflow.com

return BigDecimal.valueOf(magnitude).multiply(lnRoot)
        .setScale(scale, BigDecimal.ROUND_HALF_EVEN);
BigDecimal tolerance = BigDecimal.valueOf(5)
                  .movePointLeft(sp1);
  term = eToX.subtract(n)
        .divide(eToX, sp1, BigDecimal.ROUND_DOWN);
  x = x.subtract(term);

代码示例来源:origin: knowm/XChange

totalValue = totalValue.add(trade.getCurrency1Amount().multiply(trade.getRate()));
totalQuantity = totalQuantity.add(trade.getCurrency1Amount());
totalFee = totalFee.add(trade.getCommissionPaid());
 totalValue.divide(totalQuantity, 8, BigDecimal.ROUND_HALF_UP);

代码示例来源:origin: apache/hbase

/**
 * Compute a throughput rate in MB/s.
 * @param rows Number of records consumed.
 * @param timeMs Time taken in milliseconds.
 * @return String value with label, ie '123.76 MB/s'
 */
private static String calculateMbps(int rows, long timeMs, final int valueSize, int families, int columns) {
 BigDecimal rowSize = BigDecimal.valueOf(ROW_LENGTH +
  ((valueSize + (FAMILY_NAME_BASE.length()+1) + COLUMN_ZERO.length) * columns) * families);
 BigDecimal mbps = BigDecimal.valueOf(rows).multiply(rowSize, CXT)
  .divide(BigDecimal.valueOf(timeMs), CXT).multiply(MS_PER_SEC, CXT)
  .divide(BYTES_PER_MB, CXT);
 return FMT.format(mbps) + " MB/s";
}

代码示例来源:origin: stackoverflow.com

public static BigDecimal round(BigDecimal value, BigDecimal increment,
                RoundingMode roundingMode) {
  if (increment.signum() == 0) {
    // 0 increment does not make much sense, but prevent division by 0
    return value;
  } else {
    BigDecimal divided = value.divide(increment, 0, roundingMode);
    BigDecimal result = divided.multiply(increment);
    return result;
  }
}

代码示例来源:origin: macrozheng/mall

cartPromotionItem.setReduceAmount(originalPrice.subtract(skuStock.getPromotionPrice()));
cartPromotionItem.setRealStock(skuStock.getStock()-skuStock.getLockStock());
cartPromotionItem.setIntegration(promotionProduct.getGiftPoint());
  BigDecimal reduceAmount = originalPrice.subtract(ladder.getDiscount().multiply(originalPrice));
  cartPromotionItem.setReduceAmount(reduceAmount);
  cartPromotionItem.setRealStock(skuStock.getStock()-skuStock.getLockStock());
  BigDecimal reduceAmount = originalPrice.divide(totalAmount,RoundingMode.HALF_EVEN).multiply(fullReduction.getReducePrice());
  cartPromotionItem.setReduceAmount(reduceAmount);
  cartPromotionItem.setRealStock(skuStock.getStock()-skuStock.getLockStock());

代码示例来源:origin: apache/hive

protected BigDecimal trunc(BigDecimal input, int scale) {
 BigDecimal output = new BigDecimal(0);
 BigDecimal pow = BigDecimal.valueOf(Math.pow(10, Math.abs(scale)));
 if (scale >= 0) {
  pow = BigDecimal.valueOf(Math.pow(10, scale));
  if (scale != 0) {
   long longValue = input.multiply(pow).longValue();
   output = BigDecimal.valueOf(longValue).divide(pow);
  } else {
   output = BigDecimal.valueOf(input.longValue());
  }
 } else {
  long longValue2 = input.divide(pow).longValue();
  output = BigDecimal.valueOf(longValue2).multiply(pow);
 }
 return output;
}

代码示例来源:origin: stackoverflow.com

BigDecimal bd = new BigDecimal(0.1).multiply(new BigDecimal(10));
System.out.println(bd.compareTo(BigDecimal.ONE) == 0);

代码示例来源:origin: macrozheng/mall

/**
 * 计算总金额
 */
private BigDecimal calcTotalAmount(List<OmsOrderItem> orderItemList) {
  BigDecimal totalAmount = new BigDecimal("0");
  for (OmsOrderItem item : orderItemList) {
    totalAmount = totalAmount.add(item.getProductPrice().multiply(new BigDecimal(item.getProductQuantity())));
  }
  return totalAmount;
}

代码示例来源:origin: bootique/bootique

public static int extractNanosecondDecimal(BigDecimal value, long integer) {
    // !!! 14-Mar-2016, tatu: Somewhat inefficient; should replace with functionally
    //   equivalent code that just subtracts integral part? (or, measure and show
    //   there's no difference and do nothing... )
    return value.subtract(new BigDecimal(integer)).multiply(ONE_BILLION).intValue();
  }
}

相关文章