DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links