我使用此代码对值进行舍入:
Math.round(x * 100) / 100.0;
但它没有返回我需要的东西。
例如:x = 83.5067
我想要的:83.51
我得到的结果:83.5
最佳答案
如果你的输出是 double 的,它看起来会很好here
public static void main (String[] args) throws java.lang.Exception
{
double a = Math.round(83.5067 * 100) / 100.0;
System.out.println(a);
}
将打印83.51
关于java - 如何通过 JAVA 中的 Math.round 获得我想要的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27591699/