In the Android calculation or display is often used in the Java rounding and retention of 1 or more decimal places, before only using BigDecimal (can guarantee numerical accuracy, but also available to retain the number of digits), independent choice, the method is very good, transferred from http://www.cnblogs.com/ Hoojo/p/java_round_format_bigdecimal_decimalformat.html
Mode one:
double f = 3.1516;
BigDecimal B = new BigDecimal (f);
Double f1 = B.setscale (2, bigdecimal.round_half_up). Doublevalue ();
Mode two:
new Java.text.DecimalFormat ("#.00"). Format (3.1415926);
#.00 represents a two-bit decimal #.0000 four-bit decimal
, and so on ... Mode three:
double d = 3.1415926;
String result = String.Format ("%.2f", d);
%.2f%. Represents a floating-point type with a result of an arbitrary number of digits before the decimal point of 2 representing a two-bit decimal format.
//Method four:
Math.Round (5.2644555 *) * 0.01D;
String.Format ("%0" + + "D", 23) 23 less than 15 is on the front complement 0