List of usage examples for java.math BigDecimal abs
public BigDecimal abs(MathContext mc)
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(2); MathContext mc1 = new MathContext(4); BigDecimal bg1 = new BigDecimal("123.1234"); // assign absolute value of bg1 to bg2 rounded to 2 precision using mc BigDecimal bg2 = bg1.abs(mc); // assign absolute value of bg1 to bg3 rounded to 4 precision using mc1 BigDecimal bg3 = bg1.abs(mc1); System.out.println(bg2);/*from ww w .java 2 s . c o m*/ System.out.println(bg3); }