Solved

round up a double to two decimal places

Posted on 2007-04-09
4
3,042 Views
Last Modified: 2008-01-09
Is there a way to round to the hundreds spot in a double?  I am adding nickels dimes and quarters and sometimes I get some screwy number, I need to display this in a total window (text field) as money is deposited/deducted but I don't see an easy way to do this, I was just hopnig I missed it.

Thanks
0
Comment
Question by:urobins
  • 2
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 18879732
Use a DecimalFormat when displaying it:

http://www.objects.com.au/java/qa/1647357140.html
0
 

Author Comment

by:urobins
ID: 18879756
What library do I need to use to do this?
0
 
LVL 92

Expert Comment

by:objects
ID: 18879782
java.text
0
 

Author Comment

by:urobins
ID: 18879789
Thanks I just found it :)

once again you have answered my question with ease... I really appreciate it!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
backtracking recursion  code 19 53
mockito example issue 8 62
split string containing \r\n in Java 46 38
Apps blocked by Java 9 55
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now