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