Description Of BigDecimal: unscaledValue()
The java.math.BigDecimal.unscaledValue() returns a BigInteger whose value is the unscaled value of this BigDecimal. (Computes (this * 10this.scale()))BigDecimal.unscaledValue() method returns the unscaled value of this BigDecimal.
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.12");
BigDecimal bg2 = new BigDecimal("-245.67");
// assign unscaledValue of bg1,bg2 to bi1,bi2
BigInteger bi1 = bg1.unscaledValue();
BigInteger bi2 = bg2.unscaledValue();
String str1 = "The Unscaled Value of " + bg1 + " is " + bi1;
String str2 = "The Unscaled Value of " + bg2 + " is " + bi2;
System.out.println(str1);
System.out.println(str2);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น