Description Of BigDecimal: precision()
The java.math.BigDecimal.precision() returns the precision of this BigDecimal . (The precision is the number of digits in the unscaled value.)BigDecimal.precision() method returns the precision of this BigDecimal .
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("0123.234"); BigDecimal bg2 = new BigDecimal("523.0"); // assign the result of precision of bg1, bg2 to i1 and i2 int i1 = bg1.precision(); int i2 = bg2.precision(); String str1 = "The precision of " + bg1 + " is " + i1; String str2 = "The precision of " + bg2 + " is " + i2; // print the values of i1, i2 System.out.println(str1); System.out.println(str2); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น