Description Of BigDecimal: abs()
The java.math.BigDecimal.abs() returns a BigDecimal whose value is the absolute value of this BigDecimal, and whose scale is this.scale().BigDecimal.abs() This method returns the absolute value of the called value i.e abs(this).
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { BigDecimal de1 = new BigDecimal("456"); BigDecimal de2 = new BigDecimal("-456"); System.out.println("Absolute value of " + de1 + " is " + de1.abs()); // Absolute value of 456 is 456 System.out.println("Absolute value of " + de2 + " is " + de2.abs()); // Absolute value of -456 is 456 } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น