private Double scientDouble;
public Double getScientDouble() {
return scientDouble;
}
public void setScientDouble(Double scientDouble) {
this.scientDouble = scientDouble;
}
/**
* @description:给Double类型赋值过大,或者过小时产生科学计数法.
* 把科学计数法转换成浮点数表示
* @author:
* @date: 2019/8/21
* @param null:
* @return:
*/
public static String scientificCountToFloat(Double scientStr){
System.out.println(scientStr);
String str[]=scientStr.toString().split("-");
for (int i = 0; i <str.length ; i++) {
System.out.println(str[i]);
}
NumberFormat nf = NumberFormat.getInstance();
//设置小数位数,通过算出科学计数法的小数位数,然后设置小数位数
if (str.length>1){
nf.setMaximumFractionDigits(Integer.valueOf(str[1]));
}
//取消科学计数法
nf.setGroupingUsed(false);
return nf.format(scientStr);
}
public static void main(String[] args) {
MathUtil mathUtil=new MathUtil();
mathUtil.setScientDouble(0.00000000000000000001);
System.out.println(scientificCountToFloat(mathUtil.getScientDouble()););
}