- Java.math 包補充說明
- Java.math - 列舉
- Java.math - 討論
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 的值。
返回值
此方法返回一個值為 this | val 的 BigInteger 物件。
異常
無
示例
以下示例演示了 math.BigInteger.or() 方法的用法。
package com.tutorialspoint;
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
java_math_biginteger.htm
廣告