Description Of BigDecimal: intValue()
The java.math.BigDecimal.intValue() converts this BigDecimal to an int . This conversion is analogous to the narrowing primitive conversion from double to short as defined in section 5.1.3 of The Java? Language Specification : any fractional part of this BigDecimal will be discarded, and if the resulting "BigInteger" is too big to fit in an int , only the low-order 32 bits are returned. Note that this conversion can lose information about the overall magnitude and precision of this BigDecimal value as well as return a result with the opposite sign.BigDecimal.intValue() method returns this BigDecimal converted to an int .
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("-75.00"); BigDecimal bg2 = new BigDecimal("25.60"); BigDecimal bg3 = new BigDecimal("25"); int b1 = bg1.intValue(); int b2 = bg2.intValue(); int b3 = bg3.intValue(); System.out.println(b1); System.out.println(b2); System.out.println(b3); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น