- 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 perform XOR operation on BigInteger
The java.math.BigInteger.xor(BigInteger val) returns a BigInteger whose value is (this ^ val). This method returns a negative BigInteger if and only if exactly one of this and val are negative. Here, “val” is the value to be XOR'ed with this BigInteger.
Firstly, create two BigInteger objects −
one = new BigInteger("6"); two = new BigInteger("-5");
Now, perform XOR −
three = one.xor(two);
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 = new BigInteger("-5"); three = one.xor(two); System.out.println("Result: " +three); } }
Output
Result: -3
- Related Articles
- Java Program to perform AND operation on BigInteger
- Java Program to implement NOT operation on BigInteger
- Java Program to implement OR operation on BigInteger
- Java Program to implement andNot operation on BigInteger
- How to perform Bitwise XOR operation on two images using Java OpenCV?
- Program to perform XOR operation in an array using Python
- How to perform bitwise XOR operation on images in OpenCV Python?
- Java Program to perform an XOR on a set of Booleans
- Java Menu Driven Program to Perform Array Operation
- Java Menu Driven Program to Perform Queue Operation
- Java Menu Driven Program to Perform Matrix Operation
- C program to perform union operation on two arrays
- C program to perform intersection operation on two arrays
- How to perform Bitwise Not operation on images using Java OpenCV?
- How to perform Bitwise OR operation on two images using Java OpenCV?

Advertisements