Discussions

EJB design: java.lang.Double precision

  1. java.lang.Double precision (3 messages)

    Hi all, I have a Double with this value 136546.215454 and I want to convert it to: 136546.21 How can I do that (Only 2 decimals after ".")

    Regards Daniel

    Threaded Messages (3)

  2. java.lang.Double precision[ Go to top ]

    BigDecimal roundfinalPrice = new BigDecimal(finalPrice.doubleValue()).setScale(2,BigDecimal.ROUND_HALF_UP);
    Double doublePrice= new Double(roundfinalPrice.doubleValue());
  3. java.lang.Double precision[ Go to top ]

    Ok thanks, I proved it with a number like this 123.1234 and it works fine (y) but when you have a Double like this: 1.2223233545123E10 and apply what you said it return the same value: 1.2223233545123E10, how I can solved that??
  4. java.lang.Double precision[ Go to top ]

    use
       +-java.text.DecimalFormat class for all kinds of decimal formatting and other similar classes for toher types of formatting. they are all in java.text.package.

    cheers
    -vaheesan selvarajah
    http://vahees.blogspot.com