Tabnine Logo
BigDecimal.add
Code IndexAdd Tabnine to your IDE (free)

How to use
add
method
in
java.math.BigDecimal

Best Java code snippets using java.math.BigDecimal.add (Showing top 20 results out of 8,640)

Refine searchRefine arrow

  • BigDecimal.<init>
  • BigDecimal.divide
  • BigDecimal.multiply
  • BigDecimal.valueOf
  • BigDecimal.subtract
  • Test.<init>
  • PrintStream.println
origin: knowm/XChange

/**
 * Returns the total amount of the <code>currency</code> in this balance.
 *
 * @return the total amount.
 */
public BigDecimal getTotal() {
 if (total == null) {
  return available.add(frozen).subtract(borrowed).add(loaned).add(withdrawing).add(depositing);
 } else {
  return total;
 }
}
origin: redisson/redisson

/**
 * Returns <code>BigDecimal</code> value of JD.
 */
@SuppressWarnings({"UnpredictableBigDecimalConstructorCall"})
public BigDecimal toBigDecimal() {
  BigDecimal bd = new BigDecimal(integer);
  return bd.add(new BigDecimal(fraction));
}
origin: stackoverflow.com

 BigDecimal _0_1 = new BigDecimal(0.1);
BigDecimal x = _0_1;
for(int i = 1; i <= 10; i ++) {
  System.out.println(i+" x 0.1 is "+x+", as double "+x.doubleValue());
  x = x.add(_0_1);
}
origin: macrozheng/mall

private BigDecimal calcTotalAmount(List<CartPromotionItem> cartItemList) {
  BigDecimal total = new BigDecimal("0");
  for (CartPromotionItem item : cartItemList) {
    BigDecimal realPrice = item.getPrice().subtract(item.getReduceAmount());
    total=total.add(realPrice.multiply(new BigDecimal(item.getQuantity())));
  }
  return total;
}
origin: apache/nifi

public static void main(String[] args) throws Exception {
  BigDecimal totalDataSize = new BigDecimal("0.0");
  BigDecimal max = new BigDecimal("0.0");
  BigDecimal min = new BigDecimal("0.0");
  BigDecimal avg = new BigDecimal("0.0");
  long maxQueueSize       = 0L;
  InputStream gzipStream = new GZIPInputStream(fileStream);
  System.out.println("Using flow=" + input);
            ? convertSizeToByteValue(maxDataSize) : new BigDecimal("0.0");
        numberOfConnections++;
        avg = avg.add(byteValue);
        String dataQueueSize = maxWorkQueueSize.getElementsByTagName("maxWorkQueueSize").item(0)
            .getTextContent();
          min = byteValue;
        totalDataSize = totalDataSize.add(byteValue);
origin: knowm/XChart

tickLabels.add(numberFormatter.format(BigDecimal.valueOf(maxValue).doubleValue()));
tickLocations.add(workingSpace / 2.0);
return;
BigDecimal gridStepBigDecimal = new BigDecimal(gridStep, MathContext.DECIMAL64);
 tickLabels.add(numberFormatter.format(BigDecimal.valueOf((maxValue + minValue) / 2.0)));
 tickLocations.add(workingSpace / 2.0);
 return;
} else if (firstPositionAsDouble == Double.NEGATIVE_INFINITY) {
 firstPosition = BigDecimal.valueOf(-1 * Double.MAX_VALUE);
} else {
 try {
 } catch (java.lang.NumberFormatException e) {
  System.out.println(
    "Some debug stuff. This happens once in a blue moon, and I don't know why.");
  System.out.println("scale: " + scale);
  System.out.println("exponent: " + exponent);
  System.out.println("gridStep: " + gridStep);
  System.out.println("cleanedGridStep: " + cleanedGridStep);
  value.compareTo(BigDecimal.valueOf(maxValue + 2 * cleanedGridStep.doubleValue())) < 0;
  value = value.add(cleanedGridStep)) {
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: knowm/XChange

public BigDecimal getAveragePrice() {
 return low.add(high).divide(new BigDecimal("2"));
}
origin: com.ning.billing/killbill-invoice

@Test(groups = "fast")
public void testDoubleProRation_TargetDateInSecondProRationPeriod() throws InvalidDateSequenceException {
  final LocalDate startDate = invoiceUtil.buildDate(2011, 1, 1);
  final LocalDate targetDate = invoiceUtil.buildDate(2012, 1, 17);
  final LocalDate endDate = invoiceUtil.buildDate(2012, 1, 27);
  BigDecimal expectedValue;
  expectedValue = FOURTEEN.divide(THREE_HUNDRED_AND_SIXTY_FIVE, 2 * NUMBER_OF_DECIMALS, ROUNDING_METHOD);
  expectedValue = expectedValue.add(ONE);
  expectedValue = expectedValue.add(TWELVE.divide(THREE_HUNDRED_AND_SIXTY_SIX, 2 * NUMBER_OF_DECIMALS, ROUNDING_METHOD));
  expectedValue = expectedValue.setScale(NUMBER_OF_DECIMALS, ROUNDING_METHOD);
  testCalculateNumberOfBillingCycles(startDate, endDate, targetDate, 15, expectedValue);
}
origin: prestodb/presto

@VisibleForTesting
public static BigDecimal average(LongDecimalWithOverflowAndLongState state, DecimalType type)
{
  BigDecimal sum = new BigDecimal(Decimals.decodeUnscaledValue(state.getLongDecimal()), type.getScale());
  BigDecimal count = BigDecimal.valueOf(state.getLong());
  if (state.getOverflow() != 0) {
    BigInteger overflowMultiplier = TWO.shiftLeft(UNSCALED_DECIMAL_128_SLICE_LENGTH * 8 - 2);
    BigInteger overflow = overflowMultiplier.multiply(BigInteger.valueOf(state.getOverflow()));
    sum = sum.add(new BigDecimal(overflow));
  }
  return sum.divide(count, type.getScale(), ROUND_HALF_UP);
}
origin: debezium/debezium

public static Number add(BigInteger first, double second) {
  return new BigDecimal(first).add(BigDecimal.valueOf(second));
}
origin: apache/hive

public BigDecimal randHiveBigDecimalNear(Random r, BigDecimal bigDecimal) {
 int scale = bigDecimal.scale();
 int delta = r.nextInt(10);
 if (r.nextBoolean()) {
  return bigDecimal.add(new BigDecimal(BigInteger.valueOf(delta), scale));
 } else {
  return bigDecimal.subtract(new BigDecimal(BigInteger.valueOf(delta), scale));
 }
}
origin: embulk/embulk

private BigDecimal putFractionIfValid(final Map<String, Object> hash, final String key, final int value) {
  if (value != Integer.MIN_VALUE) {
    return (BigDecimal) hash.put(key, BigDecimal.ZERO.add(BigDecimal.valueOf(value, 9)));
  }
  return null;
}
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: prestodb/presto

  private static List<BigDecimal> toBigDecimalList(BigDecimal minValue, BigDecimal maxValue, List<Long> values)
  {
    return values.stream()
        .flatMap(value -> Stream.of(maxValue.subtract(BigDecimal.valueOf(value)), minValue.add(BigDecimal.valueOf(value))))
        .collect(toImmutableList());
  }
}
origin: prestodb/presto

@Override
public SqlDecimal getExpectedValue(int start, int length)
{
  if (length == 0) {
    return null;
  }
  BigDecimal avg = BigDecimal.ZERO;
  for (int i = start; i < start + length; i++) {
    avg = avg.add(getBigDecimalForCounter(i));
  }
  avg = avg.divide(BigDecimal.valueOf(length), ROUND_HALF_UP);
  return new SqlDecimal(avg.unscaledValue(), avg.precision(), avg.scale());
}
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: knowm/XChange

public BigDecimal calcAsk() {
 return ask.add(BASIS_POINT_MULTIPLIER.multiply(askBP));
}
origin: stackoverflow.com

 BigDecimal test = new BigDecimal(0);
System.out.println(test);
test = test.add(new BigDecimal(30));
System.out.println(test);
test = test.add(new BigDecimal(45));
System.out.println(test);
origin: macrozheng/mall

private BigDecimal calcTotalAmountByproductCategoryId(List<CartPromotionItem> cartItemList,List<Long> productCategoryIds) {
  BigDecimal total = new BigDecimal("0");
  for (CartPromotionItem item : cartItemList) {
    if(productCategoryIds.contains(item.getProductCategoryId())){
      BigDecimal realPrice = item.getPrice().subtract(item.getReduceAmount());
      total=total.add(realPrice.multiply(new BigDecimal(item.getQuantity())));
    }
  }
  return total;
}
java.mathBigDecimaladd

Javadoc

Returns a new BigDecimal whose value is this + augend. The scale of the result is the maximum of the scales of the two arguments.

Popular methods of BigDecimal

  • <init>
    Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same se
  • valueOf
  • compareTo
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • doubleValue
    Converts this BigDecimal to a double. This conversion is similar to thenarrowing primitive conversio
  • setScale
    Returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by m
  • divide
  • multiply
  • toString
    Returns the string representation of this BigDecimal, using scientific notation if an exponent is ne
  • subtract
    Returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context sett
  • intValue
    Converts this BigDecimal to an int. This conversion is analogous to thenarrowing primitive conversio
  • longValue
    Converts this BigDecimal to a long. This conversion is analogous to thenarrowing primitive conversio
  • toPlainString
    Returns a string representation of this BigDecimalwithout an exponent field. For values with a posit
  • longValue,
  • toPlainString,
  • scale,
  • toBigInteger,
  • equals,
  • floatValue,
  • negate,
  • unscaledValue,
  • abs

Popular in Java

  • Finding current android device location
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Kernel (java.awt.image)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JComboBox (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now