Monday, October 6, 2025
HomeLanguagesJavaBigDecimal unscaledValue() in Java

BigDecimal unscaledValue() in Java

The java.math.BigDecimal.unscaledValue() is an inbuilt method in java that returns a BigInteger whose value is the unscaled value of a BigDecimal value. The value computes (this * 10this.scale()).

Syntax:

public BigInteger unscaledValue()

Parameters: The method does not accepts any parameter.

Return value: This method returns a BigInteger whose value is the unscaled value of this BigDecimal value.

Below program illustrates the BigDecimal.unscaledValue() method:
Program 1:




// Program to illustrate unscaledValue() method of BigDecimal 
  
import java.math.*;
  
public class Gfg {
  
    public static void main(String[] args)
    {
  
        // Creating 2 BigInteger objects
        BigInteger i1, i2;
  
        BigDecimal b1 = new BigDecimal("175.856");
        BigDecimal b2 = new BigDecimal("-275.73");
  
        // Assigning unscaledValue of BigDecimal objects b1, b2 to i1, i2
        i1 = b1.unscaledValue();
        i2 = b2.unscaledValue();
  
        // Printing i1, i2 values
        System.out.println("The Unscaled Value of " + b1 + " is " + i1);
        System.out.println("The Unscaled Value of " + b2 + " is " + i2);
    }
}


Output:

The Unscaled Value of 175.856 is 175856
The Unscaled Value of -275.73 is -27573

Program 2:




// Program to illustrate unscaledValue() method of BigDecimal 
  
import java.math.*;
  
public class Gfg {
  
    public static void main(String[] args)
    {
  
        // Creating 2 BigInteger objects
        BigInteger i1, i2;
  
        BigDecimal b1 = new BigDecimal("5.5");
        BigDecimal b2 = new BigDecimal("-2.73");
  
        // Assigning unscaledValue of BigDecimal objects b1, b2 to i1, i2
        i1 = b1.unscaledValue();
        i2 = b2.unscaledValue();
  
        // Printing i1, i2 values
        System.out.println("The Unscaled Value of " + b1 + " is " + i1);
        System.out.println("The Unscaled Value of " + b2 + " is " + i2);
    }
}


Output:

The Unscaled Value of 5.5 is 55
The Unscaled Value of -2.73 is -273

Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#unscaledValue()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32337 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6707 POSTS0 COMMENTS
Nicole Veronica
11871 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6823 POSTS0 COMMENTS
Ted Musemwa
7089 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6779 POSTS0 COMMENTS