Package java.math

Examples of java.math.BigDecimal.abs()


                // If the absolute invoiced amount >= the abs of the adjustment amount, the full amount has already been invoiced,
                //  so skip this adjustment
                if (null == adj.get("amount")) { // JLR 17/4/7 : fix a bug coming from POS in case of use of a discount (on item(s) or sale, sale here) and a cash amount higher than total (hence issuing change)
                    continue;
                }
                if (adjAlreadyInvoicedAmount.abs().compareTo(adj.getBigDecimal("amount").setScale(invoiceTypeDecimals, rounding).abs()) > 0) {
                    continue;
                }

                if ("SHIPPING_CHARGES".equals(adj.getString("orderAdjustmentTypeId"))) {
                    shipAdjustments.put(adj, adjAlreadyInvoicedAmount);
View Full Code Here


     */
    public void testAbsNeg() {
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "123809648392384754573567356745735635678902957849027687.87678287";
        assertEquals("incorrect value", result, aNumber.abs().toString());
    }

    /**
     * Abs() of a positive BigDecimal
     */
 
View Full Code Here

     */
    public void testAbsPos() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E+21";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "123809648392384754573567356745735635678902957849027687.87678287";
        assertEquals("incorrect value", result, aNumber.abs().toString());
    }

    /**
     * Abs(MathContext) of a negative BigDecimal
     */
 
View Full Code Here

        throw new XPathException(ErrorCodes.FODT0002, "Multiplication by infinity overflow");   
      }   
    }   
    final BigDecimal factor = numberToBigDecimal(other, "Operand to mult should be of numeric type; got: ");
    final boolean isFactorNegative = factor.signum() < 0;
    final DayTimeDurationValue product = new DayTimeDurationValue(duration.multiply(factor.abs()));
    if (isFactorNegative)
      {return new DayTimeDurationValue(product.negate().getCanonicalDuration());}
    return new DayTimeDurationValue(product.getCanonicalDuration());
   
  }
View Full Code Here

   
    final boolean isFactorNegative = factor.signum() < 0;   
   
    final YearMonthDurationValue product = fromDecimalMonths(
      new BigDecimal(monthsValueSigned())
      .multiply(factor.abs())
      .setScale(0, (isFactorNegative)? BigDecimal.ROUND_HALF_DOWN : BigDecimal.ROUND_HALF_UP)
    );
   
    if (isFactorNegative)
      {return product.negate();}
View Full Code Here

   
    final boolean isDivisorNegative = divisor.signum() < 0;
   
    final YearMonthDurationValue quotient = fromDecimalMonths(
      new BigDecimal(monthsValueSigned())
      .divide(divisor.abs(), 0, (isDivisorNegative)? BigDecimal.ROUND_HALF_DOWN : BigDecimal.ROUND_HALF_UP));   
   
    if (isDivisorNegative)
      {return quotient.negate();}
   
    return new YearMonthDurationValue(quotient.getCanonicalDuration())
View Full Code Here

        //  Payment Schedule
      }
      BigDecimal allocated = getAllocatedAmt();
      if (allocated != null)
      {
        allocated = allocated.abs()//  is absolute
        m_openAmt = m_openAmt.subtract(allocated);
      }
    }
    //
    if (!creditMemoAdjusted)
View Full Code Here

    final Type type1 = parameters.getType(0);
    final Object value1 = parameters.getValue(0);
    final Number result = context.getTypeRegistry().convertToNumber(type1, value1);

    final BigDecimal num = new BigDecimal(result.toString());
    return new TypeValuePair(NumberType.GENERIC_NUMBER, num.abs());
  }

  public String getCanonicalName()
  {
    return "ABS";
View Full Code Here

  public int divide(int dividend, int divisor) {
    if (dividend == 0)
      return 0;
    ArrayList<Integer> list = new ArrayList<Integer>();
    BigDecimal d0 = new BigDecimal(dividend);
    d0 = d0.abs();
    BigDecimal d1;
    BigDecimal d3 = new BigDecimal(divisor);
    d3 = d3.abs();
    int count = 0;
    boolean start = true;
View Full Code Here

    ArrayList<Integer> list = new ArrayList<Integer>();
    BigDecimal d0 = new BigDecimal(dividend);
    d0 = d0.abs();
    BigDecimal d1;
    BigDecimal d3 = new BigDecimal(divisor);
    d3 = d3.abs();
    int count = 0;
    boolean start = true;
    while (d0.compareTo(d3) == 1 || d0.compareTo(d3) == 0) {
      d1 = new BigDecimal(divisor);
      d1 = d1.abs();
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.