Package java.math

Examples of java.math.BigDecimal.signum()


  //
 
  BigDecimal b = BigDecimal.TEN;
  System.out.println(b.precision())// Number of digits in the "unscaled value". The precision of a zero value is 1.
  System.out.println(b.scale());
  System.out.println(b.signum());     // 1
 
  BigDecimal b2 =
      new BigDecimal("22222222222222222222222222222222222222222222222222222222222222222222222.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333");
  System.out.println(b2.precision())// 172. Number of digits in the "unscaled value". The precision of a zero value is 1.
  System.out.println(b2.scale());      // 101
View Full Code Here


 
  BigDecimal b2 =
      new BigDecimal("22222222222222222222222222222222222222222222222222222222222222222222222.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333");
  System.out.println(b2.precision())// 172. Number of digits in the "unscaled value". The precision of a zero value is 1.
  System.out.println(b2.scale());      // 101
  System.out.println(b2.signum());     // 1

  BigDecimal b3 =
      new BigDecimal("-22222222222222222222222222222222222222222222222222222222222222222222222.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333");
  System.out.println(b3.precision())// 172. Number of digits in the "unscaled value". The precision of a zero value is 1.
  System.out.println(b3.scale());      // 101
View Full Code Here

  BigDecimal b3 =
      new BigDecimal("-22222222222222222222222222222222222222222222222222222222222222222222222.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333");
  System.out.println(b3.precision())// 172. Number of digits in the "unscaled value". The precision of a zero value is 1.
  System.out.println(b3.scale());      // 101
  System.out.println(b3.signum());     // -1

  // RoundingMode.DOWN always goes towards 0
  // b3.precision() - b3.scale() will be the number of digits in the integer part of the BigDecimal
  MathContext mc = new MathContext(b3.precision() - b3.scale(), RoundingMode.DOWN);
  BigDecimal b3ROUNDED = b3.round(mc);
View Full Code Here

                // apply these payments to the invoice if they have any remaining amount to apply
                Iterator cpi = currentPayments.iterator();
                while (cpi.hasNext()) {
                    GenericValue payment = (GenericValue) cpi.next();
                    BigDecimal notApplied = PaymentWorker.getPaymentNotApplied(payment);
                    if (notApplied.signum() > 0) {
                        Map appl = new HashMap();
                        appl.put("paymentId", payment.get("paymentId"));
                        appl.put("invoiceId", invoiceId);
                        appl.put("billingAccountId", billingAccountId);
                        appl.put("amountApplied", notApplied);
View Full Code Here

        String invoiceIdIn = (String) context.get("invoiceId");
        String invoiceItemSeqIdIn = (String) context.get("invoiceItemSeqId");
        BigDecimal amountTotal = InvoiceWorker.getInvoiceTotal(delegator, invoiceIdIn);
        // never use equals for BigDecimal - use either signum or compareTo
        if (amountTotal.signum() == 0) {
            Debug.logWarning("Invoice [" + invoiceIdIn + "] has an amount total of [" + amountTotal + "], so no commission invoice will be created", module);
            return ServiceUtil.returnSuccess(UtilProperties.getMessage(resource,"AccountingInvoiceCommissionZeroInvoiceAmount",locale));
        }

        try {
View Full Code Here

            // make sure the divisor is not 0 to avoid NaN problems; just leave the amount as 0 and skip it in essense
            if (divisor.signum() != 0) {
                // multiply first then divide to avoid rounding errors
                amount = baseAmount.multiply(multiplier).divide(divisor, decimals, rounding);
            }
            if (amount.signum() != 0) {
                Map createInvoiceItemContext = FastMap.newInstance();
                createInvoiceItemContext.put("invoiceId", invoiceId);
                createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId);
                createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, adj.getString("orderAdjustmentTypeId"), null, invoiceTypeId, "INVOICE_ADJ"));
                createInvoiceItemContext.put("description", adj.get("description"));
View Full Code Here

            // make sure the divisor is not 0 to avoid NaN problems; just leave the amount as 0 and skip it in essense
            if (divisor.signum() != 0) {
                // multiply first then divide to avoid rounding errors
                amount = percent.multiply(divisor);
            }
            if (amount.signum() != 0) {
                Map createInvoiceItemContext = FastMap.newInstance();
                createInvoiceItemContext.put("invoiceId", invoiceId);
                createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId);
                createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, adj.getString("orderAdjustmentTypeId"), null, invoiceTypeId, "INVOICE_ADJ"));
                createInvoiceItemContext.put("description", adj.get("description"));
View Full Code Here

                amountAppliedMax = toPaymentApplyAvailable;
            }

            if (paymentApplicationId == null) {
                // only check for new application records, update on existing records is checked in the paymentApplication section
                if (toPaymentApplyAvailable.signum() == 0) {
                    errorMessageList.add(UtilProperties.getMessage(resource, "AccountingPaymentAlreadyApplied",UtilMisc.toMap("paymentId",toPaymentId), locale));
                } else {
                    // check here for too much application if a new record is
                    // added (paymentApplicationId == null)
                    if (amountApplied.compareTo(toPaymentApplyAvailable) > 0) {
View Full Code Here

                // adjust the amountAppliedMax value if required....
                if (invoiceApplyAvailable.compareTo(amountAppliedMax) < 0) {
                    amountAppliedMax = invoiceApplyAvailable;
                }

                if (invoiceTotal.signum() == 0) {
                    errorMessageList.add(UtilProperties.getMessage(resource,"AccountingInvoiceTotalZero",UtilMisc.toMap("invoiceId",invoiceId),locale));
                } else if (paymentApplicationId == null) {
                    // only check for new records here...updates are checked in the paymentApplication section
                    if (invoiceApplyAvailable.signum() == 0) {
                        errorMessageList.add(UtilProperties.getMessage(resource,"AccountingInvoiceCompletelyApplied",UtilMisc.toMap("invoiceId",invoiceId),locale));
View Full Code Here

                    GenericValue payment = (GenericValue) cpi.next();

                    if ("PMNT_VOID".equals(payment.getString("statusId")) || "PMNT_CANCELLED".equals(payment.getString("statusId")))  continue;
                   
                    BigDecimal notApplied = PaymentWorker.getPaymentNotApplied(payment);
                    if (notApplied.signum() > 0) {
                        Map appl = new HashMap();
                        appl.put("paymentId", payment.get("paymentId"));
                        appl.put("invoiceId", invoiceId);
                        appl.put("billingAccountId", billingAccountId);
                        appl.put("amountApplied", notApplied);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.