- Java.math package classes
- Java.math - Home
- Java.math - BigDecimal
- Java.math - BigInteger
- Java.math - MathContext
- Java.math package extras
- Java.math - Enumerations
- Java.math - Discussion
Java.math.BigDecimal.unscaledValue() Method
Description
The java.math.BigDecimal.unscaledValue() returns a BigInteger whose value is the unscaled value of this BigDecimal. (Computes (this * 10this.scale()).)
Declaration
Following is the declaration for java.math.BigDecimal.unscaledValue() method.
public BigInteger unscaledValue()
Parameters
NA
Return Value
This method returns the unscaled value of this BigDecimal.
Exception
NA
Example
The following example shows the usage of math.BigDecimal.unscaledValue() method.
package com.tutorialspoint; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 2 BigDecimal objects BigDecimal bg1, bg2; // create 2 BigInteger objects BigInteger bi1, bi2; bg1 = new BigDecimal("123.12"); bg2 = new BigDecimal("-245.03"); // assign unscaledValue of bg1,bg2 to bi1,bi2 bi1 = bg1.unscaledValue(); bi2 = bg2.unscaledValue(); String str1 = "The Unscaled Value of " + bg1 + " is " + bi1; String str2 = "The Unscaled Value of " + bg2 + " is " + bi2; // print bi1, bi2 values System.out.println( str1 ); System.out.println( str2 ); } }
Let us compile and run the above program, this will produce the following result −
The Unscaled Value of 123.12 is 12312 The Unscaled Value of -245.03 is -24503
java_math_bigdecimal.htm
Advertisements