这个 JAVA数学大十进制。鳞片粉( int n ) 是java上的一个内置方法,它返回一个BigDecimal,其数值等于(这个*10n)。结果的规模是巨大的 (这个比例为()–n) .
null
语法:
public BigDecimal scaleByPowerOfTen(int n)
参数: 该方法只接受一个参数 N 整数类型,指的是BigDecimal对象乘以十的幂的值。
返回值: 此方法返回值为*10n的BigDecimal对象。
下面的程序说明了上述方法:
项目1:
// Java program to demonstrate the // scaleByPowerOfTen() method import java.math.*; public class Gfg { public static void main(String[] args) { // Assign two bigecimal objects BigDecimal b1 = new BigDecimal( "754.000" ); BigDecimal b2 = new BigDecimal( "75400" ); // Assign the result of method on b1, b2 // to BigDecimal objects b3, b4 BigDecimal b3 = b1.scaleByPowerOfTen( 4 ); BigDecimal b4 = b2.scaleByPowerOfTen(- 4 ); // Print b3, b4 values System.out.println(b1 + " raised to power is " + b3); System.out.println(b2 + " raised to power is " + b4); } } |
输出:
754.000 raised to power is 7.54000E+6 75400 raised to power is 7.5400
项目2:
// Java program to demonstrate the // scaleByPowerOfTen() method import java.math.*; public class Gfg { public static void main(String[] args) { // Assign two bigecimal objects BigDecimal b1 = new BigDecimal( "200" ); BigDecimal b2 = new BigDecimal( "7540000000" ); // Assign the result of method on b1, b2 // to BigDecimal objects b3, b4 BigDecimal b3 = b1.scaleByPowerOfTen( 4 ); BigDecimal b4 = b2.scaleByPowerOfTen(- 4 ); // Print b3, b4 values System.out.println(b1 + " raised to power is " + b3); System.out.println(b2 + " raised to power is " + b4); } } |
输出:
200 raised to power is 2.00E+6 7540000000 raised to power is 754000.0000
参考: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#scaleByPowerOfTen(国际)
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END