Description Of BigDecimal: toBigInteger()
The java.math.BigDecimal.toBigInteger() converts this BigDecimal to a BigInteger.To have an exception thrown if the conversion is inexact (in other words if a nonzero fractional part is discarded), use the toBigIntegerExact() method.
BigDecimal.toBigInteger() 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.123"); BigDecimal bg2 = new BigDecimal("12.92"); BigInteger bg3 = bg1.toBigInteger(); BigInteger bg4 = bg2.toBigInteger(); System.out.println(bg3); System.out.println(bg4); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น