Package java.math

Examples of java.math.BigDecimal.doubleValue()


      Date date = (Date)aObject;
      result = fDateConverter.formatEyeFriendly(date, fLocale, fTimeZone);
    }
    else if ( aObject instanceof BigDecimal ){
      BigDecimal amount = (BigDecimal)aObject;
      result = getBigDecimalDisplayFormat().format(amount.doubleValue());
    }
    else if ( aObject instanceof Decimal ){
      Decimal money = (Decimal)aObject;
      result = getBigDecimalDisplayFormat().format(money.getAmount().doubleValue());
    }
View Full Code Here


  }
 
  public static BigDecimal getVectorLength(Node vector) {
    BigDecimal result = vector.getPointX().pow(2).add(vector.getPointY().pow(2));
   
    return BigDecimal.valueOf(Math.sqrt(result.doubleValue()));
  }
 
  public static Graph<WeightedEdge> getTriangleWithWeights(Edge firstEdge, Edge secondEdge) throws AlgorithmException, AddEdgeException {
   
    Node commonPoint = SteinersAlgorithm.getCommonPoint(firstEdge, secondEdge);
View Full Code Here

   
    // discriminant D = b * b - 4 * a * c
    BigDecimal D = b.multiply(b)
        .subtract(BigDecimal.valueOf(4).multiply(a).multiply(c));
       
    if (D.doubleValue() < 0){
      return null;
    }
   
    // find result points
    BigDecimal x1 = b.negate()
View Full Code Here

    BigDecimal y1 = a.getPointY();
    BigDecimal y2 = b.getPointY();

    BigDecimal length = x2.subtract(x1).pow(2)
        .add(y1.subtract(y2).pow(2));
    return BigDecimal.valueOf(Math.sqrt(length.doubleValue()));
  }

  public static <T extends Edge> boolean hasCycle(Graph<T> graph) {
    Stack<Node> result = new Stack<Node>();
    Node start = graph.getNodeList().get(0);
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 messageMap = UtilMisc.toMap("totalQuantity", UtilFormatOut.formatQuantity(totalQuantity.doubleValue()));

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

                    locale = Locale.getDefault();
                }
                try {
                    Double parsedRetVal = (Double) ObjectType.simpleTypeConvert(retVal, "Double", null, locale, false);
                    String template = UtilProperties.getPropertyValue("arithmetic", "accounting-number.format", "#,##0.00;(#,##0.00)");
                    retVal = UtilFormatOut.formatDecimalNumber(parsedRetVal.doubleValue(), template, locale);
                } catch (GeneralException e) {
                    String errMsg = "Error formatting number [" + retVal + "]: " + e.toString();
                    Debug.logError(e, errMsg, module);
                    throw new IllegalArgumentException(errMsg);
                }
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

    public void testGetDoubleOnDecimal() throws RepositoryException {
        BigDecimal bd1 = new BigDecimal(Long.MAX_VALUE);
        BigDecimal bd2 = new BigDecimal(Double.MIN_VALUE);

        assertEquals(bd1.doubleValue(), factory.create(bd1).getDouble());
        assertEquals(bd2.doubleValue(), factory.create(bd2).getDouble());
    }

    public void testGetLongOnDecimal() throws RepositoryException {
        BigDecimal bd1 = new BigDecimal(Long.MAX_VALUE);
        BigDecimal bd2 = new BigDecimal(Double.MIN_VALUE);
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.