在BigInteger上执行AND操作的Java程序
java.math.BigInteger.and(BigIntegerval)返回一个BigInteger,其值为(this&val)。当且仅当this和val均为负数时,此方法才返回负数BigInteger。在此,“val”是与此BigInteger进行“与”运算的值。
首先,创建BigInteger对象-
BigInteger one, two, three;
one = new BigInteger("12");
two = new BigInteger("6");对第一个和第二个对象执行AND操作-
three = one.and(two);
以下是一个例子-
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("12");
two = new BigInteger("6");
three = one.and(two);
System.out.println("Result: " +three);
}
}输出结果
Result: 4
热门推荐
10 讲课祝福语简短10字
11 宝宝祝福语诗意简短 古文
12 简短正能量生日祝福语
13 祝福语同事离职英文简短
14 祝福语女友文案简短霸气
15 女性生日祝福语简短优美
16 14年祝福语简短情话
17 送给员工美好祝福语简短
18 前程祝福语简短暖心