Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Performing Bitwise Operations with BigInteger in Java
BigInteger class is used for big integer calculations which are outside the limit of the primitive data types. It provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.
Let us work with the testBit() method in Java to perform Bitwise operation. The java.math.BigInteger.testBit(int n) returns true if and only if the designated bit is set −
The following is an example −
Example
import java.math.*;
public class BigIntegerDemo {
public static void main(String[] args) {
BigInteger one;
Boolean two;
one = new BigInteger("5");
two = one.testBit(2);
System.out.println("Result: " +two);
}
}
Output
Result: true
Advertisements
