用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 生日广州男生祝福语简短