Java BigInteger.testBit(int n)

Syntax

BigInteger.testBit(int n) has the following syntax.

public boolean testBit(int n)

Example

In the following code shows how to use BigInteger.testBit(int n) method.


//  w  w  w  .ja  v  a 2s. co  m
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    BigInteger bi = new BigInteger("10");

    Boolean b1 = bi.testBit(2);
    Boolean b2 = bi.testBit(3);
    // print b1, b2 values
    System.out.println(b1);
    System.out.println(b2);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger