import java.math.BigDecimal; import java.math.*; // import java.math.MathContext; //import java.math.RoundingMode; public class Java_BigDecimal_abs { public static void main(String args[]) { // array of characters char ch[] = { '2', '7', '5', '1', '0', '8', '9', '3', '*' }; // creating object big_0 BigDecimal big_0; // defining array indexes big_0 = new BigDecimal(ch, 0, 8); // creating BigDecimal class object big_1 // string passed in the constructor is the value of the object big_1 BigDecimal big_1 = new BigDecimal("100.0235"); MathContext mc = new MathContext(2, RoundingMode.HALF_EVEN); // Returns the absolute value of this BigDecimal object big_0, and the // default scale is 'this.scale()'. System.out.println(".abs() value of object big_0 : " + "ph[] : " + big_0.abs()); // Returns the absolute value of BigDecimal object big_1 , with rounding // as per context settings. System.out.println(".abs() value of object big_1 : " + "ph[] : " + (big_1.abs(mc)) + "\n\n object big_1 value is in scientific form, which can evaluated as " + "(10 * 100)/10 \n\t\twhich is equal to the police control room no." + " (one double zero)100"); } }