Description Of BigDecimal: toBigIntegerExact()
The java.math.BigDecimal.toBigIntegerExact() converts this BigDecimal to a BigInteger , checking for lost information. An exception is thrown if this BigDecimal has a nonzero fractional part.BigDecimal.toBigIntegerExact() method returns this BigDecimal converted to a BigInteger.
Code Example Java BigDecimal
import java.math.BigDecimal;
import java.math.BigInteger;
public class BigDecimalExam {
public static void main(String[] args) {
BigDecimal bg1 = new BigDecimal("123");
BigDecimal bg2 = new BigDecimal("12");
BigInteger bg3 = bg1.toBigIntegerExact();
BigInteger bg4 = bg2.toBigIntegerExact();
System.out.println(bg3);
System.out.println(bg4);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น