- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to implement OR operation on BigInteger
TheBigInteger.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.
Here, “val” is the value to be OR'ed with this BigInteger.
The following is an example −
Example
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); } }
Output
Result (or operation): 6
Let us see another example −
Example
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 ); } }
Output
OR operation on 9 and 16 gives 25
- Related Articles
- Java Program to implement NOT operation on BigInteger
- Java Program to implement andNot operation on BigInteger
- Java Program to perform XOR operation on BigInteger
- Java Program to perform AND operation on BigInteger
- Math Operations on BigInteger in Java
- Java Program to Implement switch statement on strings
- Java Program to shift bits in a BigInteger
- Multiply one BigInteger to another BigInteger in Java
- Java Program to implement Binary Search on char array
- Java Program to implement Binary Search on long array
- Java Program to implement Binary Search on double array
- Java Program to implement Binary Search on float array
- Java Program to implement Binary Search on an array
- How to perform Bitwise OR operation on two images using Java OpenCV?
- Java Program to flip a bit in a BigInteger

Advertisements