设置双格式的我有一个简短的公式:有2位小数
double compute,computed2;
compute=getminutes/60;
其中getminutes
是int
,我想设置的compute
有2位小数的等价物。 0.00
如何格式化带有2位小数的等价物?
例子:
compute=45/60 it should be 0.75
这是我的工作:
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.00
7.00
“* compute = 45/60它应该是0.75 *”不在Java中。尝试45.0d/60.0d –