VOOZH about

URL: https://www.geeksforgeeks.org/java/bigdecimal-scalebypoweroften-method-in-java/

⇱ BigDecimal scaleByPowerOfTen() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BigDecimal scaleByPowerOfTen() method in Java

Last Updated : 11 Mar, 2022

The java.math.BigDecimal.scaleByPowerOfTen(int n) is an inbuilt method on java that returns a BigDecimal whose numerical value is equal to (this * 10n). The scale of the result is (this.scale() - n).
Syntax: 

public BigDecimal scaleByPowerOfTen(int n)


Parameters: 
The method accepts a single parameter n of integer type which refers to the value by which BigDecimal object is multiplied to power of ten.
Return value:This method returns the BigDecimal object of value this * 10n.
Below program illustrates the above mentioned method:
Program 1: 
 


Output: 
754.000 raised to power is 7.54000E+6
75400 raised to power is 7.5400

 

Program 2: 
 


Output: 
200 raised to power is 2.00E+6
7540000000 raised to power is 754000.0000

 

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

Comment