描述
这个java.math.BigInteger.pow(int exponent)返回一个 BigInteger,其值为 (thisexponent)。 index 是整数而不是 BigInteger。
声明
以下是声明java.math.BigInteger.pow()方法。
public BigInteger pow(int exponent)
参数
exponent- 此 BigInteger 将被提升到的 index 。
返回值
此方法返回一个 BigInteger 对象,其值为 thisexponent。
异常
ArithmeticException− index 为负。这将导致操作产生非整数值。
示例
下面的例子展示了 math.BigInteger.pow() 方法的用法。
package com.tutorialspoint;
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
// create 2 BigInteger objects
BigInteger bi1, bi2;
// create and assign value to exponent
int exponent = 2;
// assign value to bi1
bi1 = new BigInteger("6");
// perform pow operation on bi1 using exponent
bi2 = bi1.pow(exponent);
String str = "Result is " + bi1 + "^" +exponent+ " = " +bi2;
// print bi2 value
System.out.println( str );
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Result is 6^2 = 36
相关用法
- Java Java.math.BigInteger.probablePrime()用法及代码示例
- Java Java.math.BigInteger.bitCount()用法及代码示例
- Java Java.math.BigInteger.shiftLeft()用法及代码示例
- Java Java.math.BigInteger.shiftRight()用法及代码示例
- Java Java.math.BigInteger.flipBit()用法及代码示例
- Java Java.math.BigInteger.modInverse()用法及代码示例
- Java Java.math.BigInteger.valueOf()用法及代码示例
- Java Java.math.BigInteger.add()用法及代码示例
- Java Java.math.BigInteger.not()用法及代码示例
- Java Java.math.BigInteger.multiply()用法及代码示例
- Java Java.math.BigInteger.min()用法及代码示例
- Java Java.math.BigInteger.toString()用法及代码示例
- Java Java.math.BigInteger.gcd()用法及代码示例
- Java Java.math.BigInteger.hashCode()用法及代码示例
- Java Java.math.BigInteger.and()用法及代码示例
- Java Java.math.BigInteger.divideAndRemainder()用法及代码示例
- Java Java.math.BigInteger.bitLength()用法及代码示例
- Java Java.math.BigInteger.clearBit()用法及代码示例
- Java Java.math.BigInteger.isProbablePrime()用法及代码示例
- Java Java.math.BigInteger.mod()用法及代码示例
注:本文由纯净天空筛选整理自 Java.math.BigInteger.pow() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。