Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Re: Roundup Problem" Watch "Re: Roundup Problem" New topic

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?


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

Joined: Mar 09, 2005
Posts: 16

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

Good guy
It is sorta covered in the JavaRanch Style Guide.
subject: Re: Roundup Problem