double
f =
3.1516
;
BigDecimal b =
new
BigDecimal(f);
f1 = b.setScale(
2
, BigDecimal.ROUND_HALF_UP).doubleValue();