怎么用java计算出2的64次方
Assuming that you would like a detailed answer to this question:
Java has a built-in class for handling big numbers, called BigInteger. This class has a method called pow() which calculates the power of a number.
Therefore, to calculate 2 to the 64th power using Java, you would use the following code:
import java.math.BigInteger;
public class TwoToThe64th {
public static void main(String[] args) {
BigInteger two = new BigInteger("2");
System.out.println(two.pow(64));
}
}
This code would output the following:
18446744073709551616
相关文章