Description Of BigDecimal: floatValue()
The java.math.BigDecimal.floatValue() converts this BigDecimal to a float . This conversion is similar to the narrowing primitive conversion from double to float as defined in section 5.1.3 of The Java? Language Specification : if this BigDecimal has too great a magnitude to represent as a float , it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. Note that even when the return value is finite, this conversion can lose information about the precision of the BigDecimal value.BigDecimal.floatValue() method returns this BigDecimal converted to a float.
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("25.00"); BigDecimal bg2 = new BigDecimal("25.00"); BigDecimal bg3 = new BigDecimal("25"); float b1 = bg1.floatValue(); float b2 = bg2.floatValue(); float b3 = bg3.floatValue(); System.out.println(b1); System.out.println(b2); System.out.println(b3); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น