ava.math.BigInteger.xor() Method
Description
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.
Declaration
Following is the declaration for java.math.BigInteger.xor() method.
public BigInteger xor(BigInteger val)
Parameters
val − Value to be XOR'ed with this BigInteger.
Return Value
This method returns a BigInteger of value, this ^ val.
Exception
NA
Example
The following example shows the usage of math.BigInteger.xor() method.
package com.tutorialspoint;
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
// create 3 BigInteger objects
BigInteger bi1, bi2, bi3;
bi1 = new BigInteger("8");
bi2 = new BigInteger("-6");
// perform xor on bi1, bi2 and assign result to bi3
bi3 = bi1.xor(bi2);
String str = "XOR operation " +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 −
XOR operation 8 and -6 gives -14
java_math_biginteger.htm
Advertisements