float f =123456.6789f;
double d=123456789.123456789;
System.out.printf("f=%-30.12f\n",f);
System.out.printf("d=%-30.12f\n",d);
结果
f=123456.679687500000
d=123456789.123456790000
float f =123456.6789f;
double d=123456789.123456789;
System.out.printf("f=%-30.12f\n",f);
System.out.printf("d=%-30.12f\n",d);
结果
f=123456.679687500000
d=123456789.123456790000
相当于使用printf规定了输出格式,比如左对齐,右对齐等
可以参考