Package java.math

Examples of java.math.BigDecimal.doubleValue()


  public int hashCode()
  {
    long longVal;
    BigDecimal localValue = getBigDecimal();

    double doubleVal = (localValue != null) ? localValue.doubleValue() : 0;

    if (Double.isInfinite(doubleVal))
    {
      /*
       ** This loses the fractional part, but it probably doesn't
View Full Code Here


        } else {
            amount = BigDecimal.ZERO;
        }

        // check for required amount
        if ((ProductWorker.isAmountRequired(delegator, productId)) && (amount == null || amount.doubleValue() == 0.0)) {
            request.setAttribute("product_id", productId);
            request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource_error, "cart.addToCart.enterAmountBeforeAddingToCart", locale));
            return "product";
        }
View Full Code Here

        //Determine where to send the browser
        if (controlDirective.equals(ERROR)) {
            return "error";
        } else {
            totalQuantity = (BigDecimal)result.get("totalQuantity");
            Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("totalQuantity", UtilFormatOut.formatQuantity(totalQuantity.doubleValue()));

            request.setAttribute("_EVENT_MESSAGE_",
                                  UtilProperties.getMessage(resource_error, "cart.add_category_defaults",
                                          messageMap, locale));
View Full Code Here

   * http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html#BigDecimal%28double%29
   */
  public void testBigDecimalsDoubles()
  {
    BigDecimal bd = new BigDecimalConverter().convertToObject("0.1", Locale.US);
    assertTrue(bd.doubleValue() == 0.1d);

    bd = new BigDecimalConverter().convertToObject("0,1", Locale.GERMAN);
    assertTrue(bd.doubleValue() == 0.1d);
  }
}
View Full Code Here

  {
    BigDecimal bd = new BigDecimalConverter().convertToObject("0.1", Locale.US);
    assertTrue(bd.doubleValue() == 0.1d);

    bd = new BigDecimalConverter().convertToObject("0,1", Locale.GERMAN);
    assertTrue(bd.doubleValue() == 0.1d);
  }
}
View Full Code Here

      insPs.setObject(2,bd,java.sql.Types.DOUBLE);
      insPs.executeUpdate();
      // Check Value
      rs = selPs.executeQuery();
      rs.next();
      checkDoubleMatch(bd.doubleValue() , rs.getDouble(1));
      // Clear out the table;
      delPs.executeUpdate();
    }
    insPs.close();
    selPs.close();
View Full Code Here

            mrpEvent.put("facilityId", facilityId);
            mrpEvent.put("isLate", (isLate? "Y": "N"));
            mrpEvent.create();
        } else {
            BigDecimal qties = newQuantity.add(mrpEvent.getBigDecimal("quantity"));
            mrpEvent.put("quantity", qties.doubleValue());
            if (!UtilValidate.isEmpty(eventName)) {
                String existingEventName = mrpEvent.getString("eventName");
                mrpEvent.put("eventName", (UtilValidate.isEmpty(existingEventName)? eventName: existingEventName + ", " + eventName));
            }
            if (isLate) {
View Full Code Here

    // numerics: fractional
    public float getFloatValue()
        { BigDecimal bd = getBigDecimalValue(); return bd == null ? 0.0f : bd.floatValue(); }
    public double getDoubleValue()
        { BigDecimal bd = getBigDecimalValue(); return bd == null ? 0.0 : bd.doubleValue(); }
    public BigDecimal getBigDecimalValue()
        { throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
                new Object[] {getPrimitiveTypeName(), "numeric"}); }

    // numerics: integral
View Full Code Here

        BigDecimal b = (BigDecimal)v;
        if (b == null){
            dataOutput.writeBoolean(false);
        } else {
            dataOutput.writeBoolean(true);
            dataOutput.writeDouble(b.doubleValue());           
        }
    }
   
  public void bind(DataBind b, BigDecimal value) throws SQLException {
    if (value == null){
View Full Code Here

            BigDecimal bigSeconds = new BigDecimal(this.durationInNanos).divide(new BigDecimal(1000000000));
            // Calculate the minutes, and round to lose the seconds
            int minutes = bigSeconds.intValue() / 60;
            // Remove the minutes from the seconds, to just have the remainder of seconds
            double dMinutes = minutes;
            double seconds = bigSeconds.doubleValue() - dMinutes * 60;
            // Now compute the number of full hours, and change 'minutes' to hold the remainding minutes
            int hours = minutes / 60;
            minutes = minutes - (hours * 60);
            this.components = new Components(hours, minutes, seconds);
        }
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.