Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Colleen Burton   on Jan 16 In Java Category.

  
Question Answered By: Jennifer Davis   on Jan 16

I can give you the solution of the first problem.

The following method will help you to do precision upto any digits--

float getPrecisionRound (float value, int precision)
{
String sPattern = "####.0";
for (int i=1;i<precision ; i++)
sPattern += "0";
java.text.DecimalFormat df
= new java.text.DecimalFormat(sPattern);

return Float.parseFloat (df.format(value));
}

So u call this method as --> getPrecisionRound (1.23456,3)
Output ==> 1.234

Share: 

 

This Question has 11 more answer(s). View Complete Question Thread

 


Tagged: