Monday, April 13, 2009

Java Set Precision

Sometimes it does feel odd to search Mbs and Mbs of API Documentation to accomplish a simple task like setting precision after decimal point in java.

ive searched for many articles over google, but found the most of them confusing. This was the best and the most simplest way i could find to set precision after decimal point in calculations while working with primitive data-types like double and float.

this is a small patch of code in java to set precision after the decimal point in handling float and double related data-types.

the above code is self-explanatory as ive inserted comments.