用Java将一个BigInteger乘到另一个BigInteger
BigInteger类用于超出原始数据类型限制的大整数计算。它提供了用于模块化算术,GCD计算,素数测试,素数生成,位操作和其他一些其他运算的操作。
要将一个BigInteger乘以另一个,请使用BigIntegermultiply()方法。
首先,让我们创建一些对象-
BigInteger one, two, three;
one = new BigInteger("2");
two = new BigInteger("8");将以上乘以并将其分配给第三个对象-
three = one.multiply(two);
以下是一个例子-
示例
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("2");
two = new BigInteger("8");
three = one.multiply(two);
String res = one + " * " + two + " = " +three;
System.out.println("Multiplication: " +res);
}
}输出结果
Multiplication: 2 * 8 = 16
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志