如何改变这个数字:5.8774367E-7
到0.00000058774367
?非常感谢。代码:
float Deal_order = Deal_factor*(float)Order_value;
System.out.println("Deal Order is:" + Deal_order);
花药的问题:我如何在GUI中做同样的事情?
textField_9.setText (Float.toString (Deal_factor));
谢谢你的帮助
使用printf()
System.out.printf("Deal Order is: %.14fn", Deal_order);
点后面的部分(在这个例子中是14)是你的数字的小数位数。
https://docs.oracle.com/javase/tutorial/java/data/numberformat.html不使用'println',您可以轻松地使用'printf'来格式化输出
System.out.printf("Deal order is: %.15fn", Deal_order );
您可以使用printf
设置格式。
试题:
System.out.printf("Deal order is: %.10fn", Deal_order);
对于大的小数位数,可以搜索BigDecimal