Java-math-biginteger-andnot
提供:Dev Guides
Java.math.BigInteger.andNot()メソッド
説明
- java.math.BigInteger.andNot(BigInteger val)*は、値が(this&〜val)であるBigIntegerを返します。 and(val.not())と同等のこのメソッドは、マスキング操作の便宜上提供されています。 このメソッドは、これが負でvalが正の場合にのみ、負のBigIntegerを返します。
宣言
以下は* java.math.BigInteger.andNot()*メソッドの宣言です。
public BigInteger andNot(BigInteger val)
パラメーター
*val* -このBigIntegerと補完およびANDされる値。
戻り値
このメソッドは、値のthisおよび〜valのBigIntgerオブジェクトを返します。
例外
NA
例
次の例は、math.BigInteger.andNot()メソッドの使用法を示しています。
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");//110
bi2 = new BigInteger("3");//011
//perform andNot operation on bi1 using bi2
bi3 = bi1.andNot(bi2);
String str = "Result of andNot operation is " +bi3;;
//print bi3 value
System.out.println( str );
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
Result of andNot operation is 4