import java.text.DecimalFormat;
public class Test {
private double j=10000.2252 * 1000000000.25145* 1000000000.25145;
public static void main(String args[]) {
Test test = new Test();
System.out.println(test.j);
String hehe = test.SicenToComm(test.j);
System.out.println(hehe);
}
// 解决科学技术法的问题,四舍五入保留两位小数
public String SicenToComm(double value) {
String retValue = null;
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(2);
df.setMaximumFractionDigits(2);
retValue = df.format(value);
System.out.println(retValue);
retValue = retValue.replaceAll(",","");
return retValue;
}
}
DecimalFormat处理科学计数法
最新推荐文章于 2022-06-23 22:12:21 发布