# BigInteger or() method in Java

Prerequisite: BigInteger Basics

The java.math.BigInteger.or(BigInteger val) method is used to perform bitwise OR of two BigIntegers. One of the BigInteger is passed in parameter and the other on which the function is called. This method returns a negative number if either of the BigIntegers used with the function is negative. OR() method of BigInteger apply bitwise OR operation upon the current bigInteger and bigInteger passed as parameter.

Syntax:

`public BigInteger or(BigInteger val)`

Parameters: The method accepts one parameter val of BigInteger type and refers to the value to be OR’ed with this BigInteger.

Return Value: The method returns returns bitwise-OR of the current bigInteger with the bigInteger val.

Example:

```Input: value1 = 2300 , value2 = 3400
Output: 3580
Explanation:
Binary of 2300 = 100011111100
Binary of 3400 = 110101001000
OR of 100011111100 and 110101001000 = 110111111100
Decimal of 110111111100 = 3580.

Input: value1 = 54298 , value2 = 64257
Output: 65307
```

Below program illustrate the or() method of BigInteger Class:

 `/* ` `*Program Demonstrate or() method of BigInteger  ` `*/` `import` `java.math.*; ` ` `  `public` `class` `GFG { ` ` `  `    ``public` `static` `void` `main(String[] args) ` `    ``{ ` ` `  `        ``// Creates 2 BigInteger objects ` `        ``BigInteger biginteger = ``new` `BigInteger(``"2300"``); ` `        ``BigInteger val = ``new` `BigInteger(``"3400"``); ` ` `  `        ``// Call or() method to find (biginteger | val) ` `        ``BigInteger biggerInteger = biginteger.or(val); ` ` `  `        ``String result = ``"Result of OR operation between "` `+ biginteger + ``" and "` `                        ``+ val + ``" is "` `+ biggerInteger; ` ` `  `        ``// Print result ` `        ``System.out.println(result); ` `    ``} ` `} `

Output:

```Result of OR operation between 2300 and 3400 is 3580
``` My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : Akanksha_Rai

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.