Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Promoted
What's the best way to round a value to two decimal places in java?
Any help would be appreciated
Thanks x
2 Answers
Relevance
- 1 decade ago
float p = (float)Math.pow(10,digits);
number=number*p;
float tmp = Math.round(number);
float f=(float)tmp/p;
in the above example digits is the number of digits u want in the resultant float value.
number is the value which u want to round off.
Still have questions? Get your answers by asking now.