private static void TestLogic()
{
float n1 = 0.1f;
float n2 = 123.126423f;
float n3 = 0.123123f;
float n4 = 1.1f;
String tmp = ""; // 输出
tmp += "\r\n " + F2(n1); // 0.100
tmp += "\r\n " + F2(n2); // 123.13
tmp += "\r\n " + F2(n3); // 0.123
tmp += "\r\n " + F2(n4); // 1.10
System.out.print(tmp);
Log.i("Tipper", tmp);
}
/** 将数值格式化 */
private static String F2(float num)
{
DecimalFormat decimalFormat= new DecimalFormat("0.00");
if(num < 1) decimalFormat= new DecimalFormat("0.000");
String Str=decimalFormat.format(num);
return Str;
}