BigInteger to String

In this chapter you will learn:

  1. How to Convert BigInteger to String
  2. How to convert BigInteger to String with given radix

Convert BigInteger to String

String toString() Returns the decimal String representation of this BigInteger.

import java.math.BigInteger;
/*  j  a  v  a  2  s . com*/
public class Main {
  public static void main(String[] argv) throws Exception {
    BigInteger bi = new BigInteger("1023"); 
    String s = bi.toString();
    System.out.println(s);
  }
}

The output:

Convert BigInteger to String with given radix

String toString(int radix) Returns the String representation of this BigInteger in the given radix.

import java.math.BigInteger;
/*j  av a  2  s. com*/
public class Main {
  public static void main(String args[]) {
    BigInteger n = new BigInteger( new byte[] { 0x1, 0x00, 0x00 } );
    System.out.println(n.toString(10));
  }
}

The output:

Next chapter...

What you will learn in the next chapter:

  1. How to calculate Big andNot on BigInteger
  2. How to get the number of bit in a BigInteger
  3. How to clear designated bit from BigInteger
  4. How to flip designated bit in BigInteger
  5. How to negate a BigInteger
  6. How to do not operation on BigInteger
  7. How to do or operation on a BigInteger
  8. How to set bit value on BigInteger
  9. If the designated bit is set
  10. How to do bit xor calculation on BigInteger
Home » Java Tutorial » BigDecimal BigInteger

BigDecimal

    BigDecimal
    BigDecimal constants
    BigDecimal Rounding mode
    BigDecimal creation
    BigDecimal calculation
    BigDecimal convert
    BigDecimal Comparison
    BigDecimal to String
    BigDecimal decimal point
    BigDecimal precision
    BigDecimal format

BigInteger

    BigInteger class
    BigInteger creation
    BigInteger add, subtract, multiply and divide
    BigInteger power and modPow
    BigInteger conversion
    BigInteger to String
    BigInteger bit and,or,xor,test,flip,negate
    BigInteger bit shift left and right
    BigInteger prime value
    BigDecimal
    BigDecimal constants
    BigDecimal Rounding mode
    BigDecimal creation
    BigDecimal calculation
    BigDecimal convert
    BigDecimal Comparison
    BigDecimal to String
    BigDecimal decimal point
    BigDecimal precision
    BigDecimal format