Java BigDecimal.unscaledValue()
Syntax
BigDecimal.unscaledValue() has the following syntax.
public BigInteger unscaledValue()
Example
In the following code shows how to use BigDecimal.unscaledValue() method.
/*from w w w .j av a2 s .com*/
import java.math.BigDecimal;
import java.math.BigInteger;
public class Main {
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);
}
}
The code above generates the following result.