Package java.math

Examples of java.math.BigDecimal.negate()


        if (len == 0) {
            return null;
        }

        BigDecimal result = ConversionUtil.toBigDecimal(evaluateChild(0, o));
        return result != null ? result.negate() : null;
    }

    public void encodeAsString(PrintWriter pw) {
        if ((children != null) && (children.length > 0)) {
            pw.print("-");
View Full Code Here


            // positive so we store it
            // as a Big decimal. But it gets Negated right away.. to here we try
            // to covert it back
            // to a Long.
            BigDecimal bd = (BigDecimal)left;
            bd = bd.negate();

            if (BD_LONG_MIN_VALUE.compareTo(bd) == 0) {
                return Long.valueOf(Long.MIN_VALUE);
            }
            return bd;
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

  public BigDecimal next() {
    BigInteger unscaled =
        BigInteger.valueOf(rng.nextInt((int) Math.pow(10, precision)));
    BigDecimal value = new BigDecimal(unscaled, scale);
    if (rng.nextBoolean()) {
      value = value.negate();
    }
    return value;
  }
}
View Full Code Here

    int scale =
        rng.nextInt(MAX_SCALE - MIN_SCALE + 1) + MIN_SCALE
            - unscaledBD.precision();
    BigDecimal result = new BigDecimal(unscaled, -scale);
    if (rng.nextBoolean()) {
      result = result.negate();
    }
    return result;
  }

}
View Full Code Here

        if (len == 0) {
            return null;
        }

        BigDecimal result = ConversionUtil.toBigDecimal(evaluateChild(0, o));
        return result != null ? result.negate() : null;
    }

    /**
     * @since 3.2
     */
 
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

            if (max != null && max.compareTo(digitsLimit) > 0)
            {
                max = digitsLimit;
                maxInclusive = true;
            }
            digitsLimit = digitsLimit.negate();
            if (min != null && min.compareTo(digitsLimit) < 0)
            {
                min = digitsLimit;
                minInclusive = true;
            }
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

                XModel paymentLine = Journal.appendNode(model, "tr", Integer.toString(i), "");
                Journal.appendNode(paymentLine, "td", "sku", "");
                Journal.appendNode(paymentLine, "td", "desc", descString);
                Journal.appendNode(paymentLine, "td", "qty", "-");
                Journal.appendNode(paymentLine, "td", "price", UtilFormatOut.formatPrice(amount.negate()));
                Journal.appendNode(paymentLine, "td", "index", Integer.toString(i));
            }
        }
    }
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.