Java程序在BigInteger上实现OR操作
TheBigInteger.or(BigIntegerval)返回一个BigInteger,其值为(this|val)。当且仅当this或val为负数时,此方法才返回负数BigInteger。
此处,“val”是与此BigInteger进行“或”运算的值。
以下是一个例子-
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("6");
two = one.or(one);
System.out.println("Result (or operation): " +two);
}
}输出结果
Result (or operation): 6
让我们看另一个例子-
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger bi1, bi2, bi3;
bi1 = new BigInteger("9");
bi2 = new BigInteger("16");
bi3 = bi1.or(bi2);
String str = "OR operation on " + bi1 +" and " + bi2 + " gives " +bi3;
System.out.println( str );
}
}输出结果
OR operation on 9 and 16 gives 25
热门推荐
3 初八祝福语简短语
10 简短的祝福语12字
11 同事男生节祝福语简短
12 虎年公司祝福语简短的
13 生日贺卡祝福语 简短独特
14 官宣新年祝福语简短
15 恭喜朋友买车祝福语简短
16 学生节祝福语大全简短
17 小姨生日祝福语简短独特
18 姐姐女儿结婚祝福语简短