Description Of BigDecimal: byteValueExact()
The java.math.BigDecimal.byteValueExact() converts this BigDecimal to a byte , checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for a byte result then an ArithmeticException is thrownBigDecimal.xor(BigInteger val) method returns this BigDecimal converted to a byte
Code Example Java BigDecimal
import java.math.BigDecimal;
public class BigDecimalExam {
public static void main(String[] args) {
// assign values to bg1 and bg2
BigDecimal bg1 = new BigDecimal("-4");
BigDecimal bg2 = new BigDecimal("2");
byte i1 = bg1.byteValueExact();
byte i2 = bg2.byteValueExact();
// print i1,i2 values
System.out.println(i1);
System.out.println(i2);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น