在 Java 中从一个 BigInteger 中减去另一个 BigInteger
使用 Java 中的 BigInteger subtract() 方法从另一个 BigInteger 中减去一个 BigInteger。
首先,让我们创建一些对象 -
BigInteger one, two, three;
one = new BigInteger("200");
two = new BigInteger("150");减去上面的内容并将其分配给第三个对象 -
three = one.subtract(two);
以下是一个示例 -
示例
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("200");
two = new BigInteger("150");
three = one.subtract(two);
String res = one + " - " + two + " = " +three;
System.out.println("Subtraction: " +res);
}
}输出
Subtraction: 200 - 150 = 50
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP