This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes get 2 digit places Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "get 2 digit places " Watch "get 2 digit places " New topic

get 2 digit places

Sophia Choi
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
how can I can digit places ? e.g. 12.34534 -> 12.35 or 6.3333-> 6.33
now, I am using the formula as following,
result_arr[i] = (float) Math.floor( (float) tot_weight / respondents * 10 + 0.5) /10 ;
Any other suggestions?
Barry Burd
Ranch Hand

Joined: Jun 18, 2003
Posts: 118

Try this:
import java.text.NumberFormat;
NumberFormat numFormat =


Java For Dummies, 6th Edition, Java Programming for Android Developers For Dummies
I agree. Here's the link:
subject: get 2 digit places
It's not a secret anymore!