The moose likes Beginning Java and the fly likes scaling a Double Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "scaling a Double" Watch "scaling a Double" New topic

scaling a Double

Dave Jones
Ranch Hand

Joined: Feb 20, 2005
Posts: 77
Hello Ranchers!!

I have a few Double members, with setters and getters.
I recently received a request that the getters will return a double with only two digits after the decimal points(decimal digits, that is).
e.g - the number for the number 5.123 the getter will return will return 5.12.
Now, I remembered something called "scaling" , setScale , but I can't find this method in the Double object nor in the API.

I know I can always write a small util, but I always prefer something ready.

Any suggestions??
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sounds like they really want a BigDecimal.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
You can use Decimal Format

Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
I agree. Here's the link:
subject: scaling a Double
It's not a secret anymore!