用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 好听的元旦简短祝福语