用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 出阁宴祝福语姐姐简短