set double format with 2 decimal places
本问题已经有最佳答案,请猛点这里访问。
我有一个简短的方程式:
| 1 2 3 | double compute,computed2; compute=getminutes/60; | 
其中,
例子:
| 1 | compute=45/60 it should be 0.75 | 
这是我的工作:
| 1 2 3 4 5 6 7 8 9 10 11 | DecimalFormat df2 = new DecimalFormat("00.00000"); double computed,computed2 = 00.000; computed=60/getitbyminutes; df2.format(computed); computed2=computed-8; df2.format(computed2); System.out.printf("%1$.2f",computed); System.out.println(); System.out.printf("%1$.2f",computed2); | 
输出就像:
| 1 2 | 1.00 7.00 | 
只需以正确的方式格式化输出:
| 1 2 3 | 
把它铸成两倍
| 1 | 
然后使用彼得提到的