Java tutorial
import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("123.12678"); // set scale of bg1 to 2 in bg2 using floor as rounding mode BigDecimal bg2 = bg1.setScale(2, RoundingMode.FLOOR); String str = bg1 + " after changing the scale to 2 and rounding is " + bg2; // print bg2 value System.out.println(str); } }