Description Of BigDecimal: valueOf(double val)
The java.math.BigDecimal.valueOf(double val) translates a double into a BigDecimal , using the double 's canonical string representation provided by the Double.toString(double) method.Note: This is generally the preferred way to convert a double (or float ) into a BigDecimal , as the value returned is equal to that resulting from constructing a BigDecimal from the result of using Double.toString(double) .
BigDecimal.valueOf(double val) method returns a BigDecimal whose value is equal to or approximately equal to the value of val.
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { Double d = new Double("123.45678"); BigDecimal bg = BigDecimal.valueOf(d); System.out.println(bg); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น