Java-math-biginteger-divide
提供:Dev Guides
Java.math.BigInteger.divide()メソッド
説明
- java.math.BigInteger.divide(BigInteger val)*は、値が(this/val)であるBigIntegerを返します。
宣言
以下は* java.math.BigInteger.divide()*メソッドの宣言です。
public BigInteger divide(BigInteger val)
パラメーター
*val* -このBigIntegerを分割する値。
戻り値
このメソッドは、値/this/valのBigIntegerオブジェクトを返します。
例外
*ArithmeticException* -valがゼロの場合。
例
次の例は、math.BigInteger.divide()メソッドの使用方法を示しています。
package com.finddevguides;
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
//create 3 BigInteger objects
BigInteger bi1, bi2, bi3;
bi1 = new BigInteger("-100");
bi2 = new BigInteger("3");
//divide bi1 with bi2
bi3 = bi1.divide(bi2);
String str = "Division result is " +bi3;
//print bi3 value
System.out.println( str );
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
Division result is -33