Java.math.BigInteger.or() Method
Description
The java.math.BigInteger.or(BigInteger val) returns a BigInteger whose value is (this | val). This method returns a negative BigInteger if and only if either this or val is negative.
Declaration
Following is the declaration for java.math.BigInteger.or() method.
public BigInteger or(BigInteger val)
Parameters
val − Value to be OR'ed with this BigInteger.
Return Value
This method returns a BigInteger object whose value is this | val.
Exception
NA
Example
The following example shows the usage of math.BigInteger.or() method.
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 );
}
}
Let us compile and run the above program, this will produce the following result −
OR operation on 6 and 8 gives 14
java_math_biginteger.htm
Advertisements