我double
类型的变量,我需要打印在高达的精度3位小数,但它不应该有任何尾随零...格式化浮点数
如。我需要
2.5 // not 2.500
2 // not 2.000
1.375 // exactly till 3 decimals
2.12 // not 2.120
我试过使用DecimalFormatter
,我做错了吗?
DecimalFormat myFormatter = new DecimalFormat("0.000");
myFormatter.setDecimalSeparatorAlwaysShown(false);
谢谢。 :)
@ st0le,欢呼! – 2011-01-19 08:35:56