Package java.math

Examples of java.math.BigDecimal.signum()


            // 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<String, Object> 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<String, Object> 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)
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) {
View Full Code Here

                        try {
                            billingAccountBalance = getBillingAccountBalance(thisBillingAccountId, dctx);
                        } catch (GenericEntityException e) {
                            return ServiceUtil.returnError(e.getMessage());
                        }
                        if (billingAccountBalance.signum() == -1) {
                            billingAccountId = thisBillingAccountId;
                        }
                    }
                }
View Full Code Here

            buf[i] = bd.setScale(0, BigDecimal.ROUND_DOWN);

            bd = bd.subtract(buf[i]);
            if (i == 1) {
                if (bd.signum() != 0) {
                    throw new IllegalStateException(); // illegal carry-down
                } else {
                    carry = ZERO;
                }
            } else {
View Full Code Here

     * @throws Exception
     */
    public Node external_mul(Node startAt) throws Exception {
        startAt.isGoodArgsLength(false, 2);
        BigDecimal r = number.get();
        if(r.signum()==0){
            // cas ou la variable statique est déjà zéro.
            return Node.createExternal(new External_Decimal(r,context.get()));
        }
        int i = 1;
        int asize = startAt.size();
View Full Code Here

            // cas ou la variable statique est déjà zéro.
            return Node.createExternal(new External_Decimal(r,context.get()));
        }
        int i = 1;
        int asize = startAt.size();
        while (i < asize && r.signum() != 0)
            r = r.multiply(_getArg_lazy_(startAt, i++));
        // signum() retourne 0 si r vaut 0. Cette méthode est plus rapide que compareTo()...
        return Node.createExternal(new External_Decimal(r,context.get()));
    }
View Full Code Here

        BigDecimal r;
        do {
            old_r = number.get();
            r = old_r;
            int i = 0;
            while (i < v.length && r.signum() != 0)
                r = r.multiply(v[i++]);
        }
        while (!number.compareAndSet(old_r, r));
        return null;
    }
View Full Code Here

     * @return Node:Decimal
     * @throws Exception
     */
    public Node external_fractional(Node startAt) throws Exception {
        BigDecimal num = number.get();
        boolean negatif = num.signum()==-1;
        BigDecimal n=num.abs();
        BigDecimal n2 = BigDecimalMath.floor(n);
        n = n.subtract(n2);
        n = negatif ? n.negate(): n;
        return Node.createExternal(new External_Decimal(n,context.get()));
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.