How to get the double value that is only two digit after decimal point.
For example if the a = 190253.80846153846
then the result value should be like a = 190253.80
Try:
I have try with this:
public static DecimalFormat twoDForm = new DecimalFormat("#0.00");
in code
a = Double.parseDouble(twoDForm.format(((a))));
But i got the value like 190253.81 instead of that i want 190253.80
So what should i have to change for it ??
Because Math.round() Returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int.
Use
Math.floor()Example
Complete Source code