关于java生成科学计数法的数,一个demo程序如下。
package cn.com.happyever.remit.tools;
import java.math.BigDecimal;
public class Test {
public static void main(String[] args) {
String temp1 = "1000000000";
Double double1 = (new Double(temp1))/100*-1;
System.out.println("double1>"+double1);
String temp2 = "900000099";
Double double2 = (new Double(temp2))/100*-1;
System.out.println("double2>"+double2);
/*output:
double1>-1.0E7
double2>-9000000.99*/
//解决方案:
String temp3 = "1000000000";
BigDecimal bd2 = new BigDecimal("0.01");
BigDecimal amount = BigDecimal.valueOf(-Long.valueOf(temp3));
String strAmount = amount.multiply(bd2).toString();// 金额单位(元)
System.out.println("strAmount>"+strAmount);
/*output:strAmount>-10000000.00*/
}
}