Rounding a value


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Rounding a value

  1. #1
    Join Date
    Jul 2005
    Posts
    23

    Question Rounding a value

    Hi,

    Let say I hava a value 245.678909. I want to display it as 245.68. It is a double value. What should I do?

    Thank you.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Make a java.text.DecimalFormat like:

    static DecimalFormat df=new DecimalFormat("0.00");

    use it like

    System.out.println(df.format(aDoubleValue));

    It will do the rounding for you.
    Last edited by sjalle; 08-14-2005 at 07:16 PM.
    eschew obfuscation

Similar Threads

  1. Replies: 2
    Last Post: 09-27-2006, 07:29 PM
  2. Replies: 1
    Last Post: 07-14-2005, 08:17 AM
  3. Rounding numbers
    By Big Swifty in forum Java
    Replies: 3
    Last Post: 11-10-2002, 06:33 AM
  4. Rounding in MSH Flexgrid
    By Teddy in forum VB Classic
    Replies: 0
    Last Post: 02-14-2002, 11:14 AM
  5. Javascript rounding error
    By Wayne Hou in forum Web
    Replies: 0
    Last Post: 01-29-2001, 09:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center