Java-math-biginteger-or
提供:Dev Guides
Java.math.BigInteger.or()メソッド
説明
- java.math.BigInteger.or(BigInteger val)*は、値が(this | val)であるBigIntegerを返します。 thisまたはvalが負の場合にのみ、このメソッドは負のBigIntegerを返します。
宣言
以下は* java.math.BigInteger.or()*メソッドの宣言です。
public BigInteger or(BigInteger val)
パラメーター
*val* -このBigIntegerとOR演算される値。
戻り値
このメソッドは、次の値を持つBigIntegerオブジェクトを返します| val。
例外
NA
例
次の例は、math.BigInteger.or()メソッドの使用方法を示しています。
package com.finddevguides;
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
//create 3 BigInteger objects
BigInteger bi1, bi2, bi3;
//assign values to bi1, bi2
bi1 = new BigInteger("6");
bi2 = new BigInteger("8");
//perform or operation on bi1, bi2
bi3 = bi1.or(bi2);
String str = "OR operation on " + bi1 +" and " + bi2 + " gives " +bi3;
//print bi3 value
System.out.println( str );
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
OR operation on 6 and 8 gives 14