Java tutorial
import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("123.12345678"); // set scale of bg1 to 2 in bg2 // 0 specifies ROUND_UP BigDecimal bg2 = bg1.setScale(2, RoundingMode.UP); String str = bg1 + " after changing the scale to 2 and rounding is " + bg2; System.out.println(str); } }