0

在这个片段中,我期望“2”作为结果?

Apfloat f = new Apfloat("1.5", 50);
f = ApfloatMath.round(f, 15, RoundingMode.HALF_UP);
System.out.println(f.toString());

还是应该以不同的方式使用ApfloatMath.round()

4

1 回答 1

1

I have never heard of apfloat but one google query showed me:

round(Apfloat x, long precision, RoundingMode roundingMode)

So apparently you are rounding with a precision of 15, why do you expect 1.5 to magically become 2?

In other words: set precision to 0 or 1 (depends on the implementation)

于 2014-07-24T08:27:48.633 回答