my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Re: Roundup Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Re: Roundup Problem" Watch "Re: Roundup Problem" New topic
Author

Re: Roundup Problem

Joe Cheung
Ranch Hand

Joined: Oct 18, 2002
Posts: 104
Dear all,

I have 2 double values, 2.44 and 2.45 that I want to make a roundup with them such that it can produre "2.4" and "2.5" respectively. Does any Java API provide methods for this?

Thanks!
Joe


Joe
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
java.lang.Math has a method you can use, but you'll need to do some trickery to get it to round to different precisions (one decimal place in you case). Give it a try and post again if you can't figure out a way to work it.
tue march
Greenhorn

Joined: Mar 09, 2005
Posts: 16
Hi,

i think u have round()in java.lang.math class to solve it.

Thanks,
Good guy
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Re: Roundup Problem
 
Similar Threads
Rule Round-Up question 68
Javaranch's Java Roundup Game
Question
Can I get all the questions from the mock exam
Links not working & Rules Roundup game