BigInteger or() in Java

or(): This method is available in java.math.BigInteger class of Java.

Syntax:

BigInteger java.math.BigInteger.or(BigInteger val)

This method takes one argument of type BigInteger as its parameter. This method returns a BigInteger whose value is (this | val). (This method returns a negative BigInteger if and only if either this or val is negative.)

Parameters: One parameter is required for this method.

val: value to be OR'ed with this BigInteger.

Returns: this | val

For Example:

BigInteger bigInteger = new BigInteger("1234")

BigInteger val = new BigInteger("45")

bigInteger.or(val) = > It returns 1279.

Approach

Java

import java.math.BigInteger;

public class BigIntegeror {
    public static void main(String[] args) {

        BigInteger bigInteger = new BigInteger("1234");

        BigInteger val = new BigInteger("45");
        System.out.println(bigInteger.or(val));
    }
}

Output:

1279

No comments:

Post a Comment