Package java.math

Examples of java.math.BigDecimal.negate()


    private static final class NegDecimal extends Exec {
        static final NegDecimal INSTANCE = new NegDecimal();

        public XDecimal eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            BigDecimal bd1 = asDecimal(v1, dynEnv);
            return XDecimal.valueOf(bd1.negate());
        }
    }
}
View Full Code Here


                    bigDecimalResult = bigDecimalResult.divide(getBigDecimalMultiplier(), roundingMode);
                }
            }

            if (!status[STATUS_POSITIVE]) {
                bigDecimalResult = bigDecimalResult.negate();
            }
            return bigDecimalResult;
        } else {
            boolean gotDouble = true;
            boolean gotLongMinimum = false;
View Full Code Here

            // Ok, then, add a small integer, divide by 10 to generate digits
            D = D.add(BigDecimal.valueOf(rnd.nextInt() & 0xF)).divide(BigDecimal.valueOf(10L));
           
            // Plus switch sign every now and then
            if ((i % 3) == 0) {
                D = D.negate();
            }
        }
    }

    /*
 
View Full Code Here

        jrVO.setAccountCodeAcc02ACC06(vatAccountCodeAcc02);
        jrVO.setAccountCodeACC06(vatAccountCodeAcc02);
        jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

        if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
          jrVO.setCreditAmountACC06(totalVat.negate());
        else
          jrVO.setCreditAmountACC06(totalVat);
        jrVO.setCreditAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getCreditAmountACC06(),conv));

        jrVO.setDescriptionACC06("");
View Full Code Here

         jrVO.setAccountCodeAcc02ACC06(vatAccountCodeAcc02);
         jrVO.setAccountCodeACC06(vatAccountCodeAcc02);
         jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);

         if (docVO.getDocTypeDOC06().equals(ApplicationConsts.PURCHASE_DEBIT_NOTE_DOC_TYPE))
           jrVO.setDebitAmountACC06(totalVat.negate());
         else
           jrVO.setDebitAmountACC06(totalVat);
         jrVO.setDebitAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getDebitAmountACC06(),conv));

         jrVO.setDescriptionACC06("");
View Full Code Here

        OrderReadHelper orderReadHelper = new OrderReadHelper(orderAdjustments, orderItems);
        BigDecimal grandTotal = orderReadHelper.getOrderGrandTotal();
        if (grandTotal.compareTo(new BigDecimal(0)) != 0) {
            GenericValue adjustment = delegator.makeValue("OrderAdjustment");
            adjustment.set("orderAdjustmentTypeId", "REPLACE_ADJUSTMENT");
            adjustment.set("amount", grandTotal.negate());
            adjustment.set("comments", "ReShip Order for Order #" + originalOrderId);
            adjustment.set("createdDate", UtilDateTime.nowTimestamp());
            adjustment.set("createdByUserLogin", userLogin.getString("userLoginId"));
            cart.addAdjustment(adjustment);
        }
View Full Code Here

            }
        case DECIMAL:
            try {
                BigDecimal value = new BigDecimal(magnitude);
                return Predicates.decimalRange(
                        minus ? value.negate() : BigDecimal.ZERO,
                        plus ? value : BigDecimal.ZERO);
            } catch (NumberFormatException e) {
                throw new FormatException(MessageFormat.format(
                        "Invalid approx(~) error \"{1}\": {0}",
                        name,
View Full Code Here

      while (iterator.hasNext()) {
        invoiceMap = (Map) iterator.next();
        paymentMap = (Map) queryRunner.query(sql, invoiceMap.get("invoice_id"), mapRsh);
        balanceDue = invoiceMap.get("amount") == null ? new BigDecimal((double) 0) : (BigDecimal) invoiceMap.get("amount");
        paymentAmount = paymentMap.get("sum_amount") == null ? new BigDecimal((double) 0) : (BigDecimal) paymentMap.get("sum_amount");
        balanceDue = balanceDue.add(paymentAmount.negate());

        invoiceMap.put("amount_paid", paymentAmount);
        if (balanceDue.compareTo(new BigDecimal((double) 0)) == 0) {
          invoiceMap.put("balance_due", null);
        } else {
View Full Code Here

        } else if (val instanceof Double) {
            double valueAsDouble = ((Double) val).doubleValue();
            return new Double(-valueAsDouble);
        } else if (val instanceof BigDecimal) {
            BigDecimal valueAsBigD = (BigDecimal) val;
            return valueAsBigD.negate();
        } else if (val instanceof BigInteger) {
            BigInteger valueAsBigI = (BigInteger) val;
            return valueAsBigI.negate();
        }
        throw new JexlException(valNode, "not a number");
View Full Code Here

                    BigDecimal borrow =
                        buf[i].abs().divide(
                            FACTORS[i - 1],
                            BigDecimal.ROUND_UP);
                    if (buf[i].signum() > 0) {
                        borrow = borrow.negate();
                    }

                    // update values
                    buf[i - 1] = buf[i - 1].subtract(borrow);
                    buf[i] = buf[i].add(borrow.multiply(FACTORS[i - 1]));
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.