我的情况应该使用哪种舍入方法?

What rounding method should I use for my case?

我正在构建一个 class 将需要舍入双打。

其中,根据输入 n,它将(最多)有 n 个小数位,并尽可能跳过尾随零。

//If n = 2,

//1.697 -> 1.7  (instead of 1.70)     (edit)       
//1.000 -> 1    (instead of 1.00)             
//1.658 -> 1.66

似乎有很多舍入技术,但我不确定哪一种适用于我的情况。

如有任何帮助,我们将不胜感激。 谢谢

您应该在此处阅读有关 DecimalFormatting 的信息:https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html

虽然你的问题有点乱。为什么将 1.693 舍入为 1.7,然后将 1.658 舍入为 1.66。 你在两个方面都不同。