About
Pricing
Community
Teams
Start Free Trial
Log in
rajuvegesna
asked on
2/24/2003
Math functions
hai,
I have a calculated double value for ex. 0.15682534735275272
but i want to display only 0.15, only 2 or 3 decimal points.
can i do it,if so how?
Java
9
1
Last Comment
CEHJ
8/22/2022 - Mon
CEHJ
2/24/2003
String d = new DecimalFormat("0.00").form
at(0.15682
5347352752
72);
ASKER CERTIFIED SOLUTION
shji1
2/24/2003
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
TimYates
2/24/2003
Or do it the right way like CEHJ said ;-) *giggle*
rajuvegesna
2/24/2003
ASKER
good,but i couldnt able to keep in my prog..i am getting error,
because i want this string to be in the middle of a class file,like
String d = new DecimalFormat("0.00").form
at(p.y);
where p.y varies ...
what is the DecimalFormat actually....
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
TimYates
2/24/2003
Soz....
looked a bit closer at your code, and you are right :-/
That will perform rounding to a certain number of d.p. and is quite cool :-)
*grovel* *apologise* :-(
TimYates
2/24/2003
So "String d = new DecimalFormat("0.00").form
at(p.y);" doesn't work?
what's the error?
rajuvegesna
2/24/2003
ASKER
good,but i couldnt able to keep in my prog..i am getting error,
because i want this string to be in the middle of a class file,like
String d = new DecimalFormat("0.00").form
at(p.y);
where p.y varies ...
what is the DecimalFormat actually....
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rajuvegesna
2/24/2003
ASKER
hai Shaji ,
ur idea is good and simple..
thank u for all...
CEHJ
2/24/2003
String d = new java.text.DecimalFormat("0
.00").form
at(p.y);
Why would you want a number that is nearer to 0.16 to be displayed as 0.15?