Package java.math

Examples of java.math.BigDecimal.divide()


    Parameters.checkCondition(values.length > 0);
    BigDecimal sum = BigDecimal.ZERO;
    for (double value : values) {
      sum = sum.add(BigDecimal.valueOf(value));
    }
    return sum.divide(BigDecimal.valueOf(values.length)).doubleValue();
  }

  /**
   * Returns the arithmetic mean of the given values. This method is not
   * subject to overflow.
View Full Code Here


    Parameters.checkCondition(values.length > 0);
    BigDecimal sum = BigDecimal.ZERO;
    for (float value : values) {
      sum = sum.add(BigDecimal.valueOf(value));
    }
    return sum.divide(BigDecimal.valueOf(values.length)).doubleValue();
  }

  /**
   * Returns whether the given value is a real value. Namely, it returns
   * {@code false} if the given value is infinite or NaN, and {@code true}
View Full Code Here

      BigDecimal bdlDeg = new BigDecimal(deg);
      BigDecimal bdlMin = new BigDecimal(min);
      BigDecimal bdlSec = new BigDecimal(sec);
     
      return bdlDeg.add(bdlMin.divide(NMB_60, scale, GfrBigMath._INT_ROUNDING_MODE_)).add(bdlSec.divide(NMB_3600, scale, java.math.RoundingMode.FLOOR));
   }
  
   public static BigDecimal degToRad(BigDecimal degAngle, int scale)
   {
      return degAngle.divide(GfrBigMath.NMB_180, scale, _INT_ROUNDING_MODE_).multiply(GfrBigMath.pi(scale));
View Full Code Here

      while (more)
      {
         lastGuess = guess;
         guess = n.divide(guess, scale, _INT_ROUNDING_MODE_);
         guess = guess.add(lastGuess);
         guess = guess.divide(NMB_2, scale, _INT_ROUNDING_MODE_);

         _BDM_ERROR_ = n.subtract(guess.multiply(guess));
         if (++_INT_ITERATIONS_ >= _INT_MAX_ITERATIONS_)
         {
            System.out.println("Iter : " + _INT_ITERATIONS_ );
View Full Code Here

    return currency;
  }

  public BigDecimal getBigDecimal() {
    BigDecimal c = new BigDecimal(cents);
    return c.divide(new BigDecimal(100));
  }

  /**
   * Get the integer value without cents. eg. 1,55 euros return 1.
   */
 
View Full Code Here

        BigDecimal unitCost = ZERO;
        try {
            Map outputMap = dispatcher.runSync("getProductionRunCost", UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId", productionRunId));
            BigDecimal totalCost = (BigDecimal)outputMap.get("totalCost");
            // FIXME
            unitCost = totalCost.divide(quantity, decimals, rounding);
        } catch (GenericServiceException e) {
            Debug.logWarning(e.getMessage(), module);
            return ServiceUtil.returnError(e.getMessage());
        }
View Full Code Here

                codSurchargeApplyToNoPackages = "none".equalsIgnoreCase(codSurchargeApplyToPackages);

                if (codSurchargeApplyToNoPackages) codSurchargeAmount = "0";
                codSurchargePackageAmount = new BigDecimal(codSurchargeAmount).setScale(decimals, rounding);
                if (codSurchargeSplitBetweenPackages) {
                    codSurchargePackageAmount = codSurchargePackageAmount.divide(new BigDecimal(shipmentPackageRouteSegs.size()), decimals, rounding);
                }

                if (UtilValidate.isEmpty(destTelecomNumber)) {
                    Debug.logInfo("Voice notification service will not be requested for COD shipmentId " + shipmentId + ", shipmentRouteSegmentId " + shipmentRouteSegmentId + " - missing destination phone number", module);
                }
View Full Code Here

                            GenericValue newAdjustment = GenericValue.create(adjustment);
                            BigDecimal adjAmount = newAdjustment.getBigDecimal("amount");

                            // we use != becuase adjustments can be +/-
                            if (adjAmount != null && adjAmount.compareTo(BigDecimal.ZERO) != 0)
                                newAdjustment.set("amount", adjAmount.divide(baseQuantity, generalRounding));
                            Debug.logInfo("Cloned adj: " + newAdjustment, module);
                            item.addAdjustment(newAdjustment);
                        } else {
                            Debug.logInfo("Clone Adjustment is null", module);
                        }
View Full Code Here

                        GenericValue newAdjustment = GenericValue.create(adjustment);
                        BigDecimal adjAmount = newAdjustment.getBigDecimal("amount");

                        // we use != becuase adjustments can be +/-
                        if (adjAmount != null && adjAmount.compareTo(BigDecimal.ZERO) != 0)
                            newAdjustment.set("amount", adjAmount.divide(baseQuantity, generalRounding));
                        Debug.logInfo("Updated adj: " + newAdjustment, module);
                        this.addAdjustment(newAdjustment);
                    }
                }
            }
View Full Code Here

            }
            if (persons.compareTo(new BigDecimal("2")) == 0)
                rentalAdjustment = rentalAdjustment.add(secondPersonPerc);
        }
        rentalAdjustment = rentalAdjustment.add(new BigDecimal(100))// add final 100 percent for first person
        rentalAdjustment = rentalAdjustment.divide(new BigDecimal(100), scale, rounding).multiply(new BigDecimal(String.valueOf(length)));
//        Debug.logInfo("rental parameters....Nbr of persons:" + persons + " extra% 2nd person:" + secondPersonPerc + " extra% Nth person:" + nthPersonPerc + " Length: " + length + "  total rental adjustment:" + rentalAdjustment ,module);
        return rentalAdjustment; // return total rental adjustment
        }

    public static BigDecimal getAllOrderItemsAdjustmentsTotal(List orderItems, List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) {
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.