我想得到一个函数,现在我使用下面的函数将双精度值四舍五入为两位有效数字
private static DecimalFormatSymbols DFS;
private static DecimalFormat myFormatter;
public static String DoubleToFormatedString(double value) {
DFS = new DecimalFormatSymbols();
DFS.setDecimalSeparator('.');
myFormatter = new DecimalFormat("############.##");
myFormatter.setDecimalFormatSymbols(DFS);
return myFormatter.format(value);
}
但是有了这个函数,例如:我得到一个四舍五入的数字 2.6,我需要得到这个像 2.60。'0' 应该出现在 1 个有效数字的右侧。应该做出什么改变?或任何其他方式请帮助我