使用 Java 將一個 BigInteger 從另一個 BigInteger 中進行除法運算
使用 Java 中的 BigInteger divide() 方法將一個 BigInteger 從另一個 BigInteger 中進行除法運算。
首先,讓我們建立一些物件。
BigInteger one, two, three;
one = new BigInteger("200");
two = new BigInteger("100");對以上進行除法計算並賦值到第三個物件 −
three = one.divide(two);
以下是一個示例 −
示例
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("200");
two = new BigInteger("100");
// division
three = one.divide(two);
String res = one + " / " + two + " = " +three;
System.out.println("Result: " +res);
}
}輸出
Result: 200 / 100 = 2
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP