0

In this snippet I expected "2" as the result?

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

Or should ApfloatMath.round() be used differently?

Rudi Kershaw
  • 12,332
  • 7
  • 52
  • 77
axelclk
  • 950
  • 9
  • 28

1 Answers1

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)

nablex
  • 4,635
  • 4
  • 36
  • 51