Java BigInteger toString() method

The toString() method of Java BigInteger class is used to convert the numeric value of this BigInteger object to its equivalent string representation in a given radix or base.

Syntax:

Parameter:

radix - radix of the String representation.

Returns:

This method returns the String representation of this BigInteger in the given radix.

Exception:

NA

  • Note:
    The toString() method returns a decimal String representation of this BigInteger if radix is not given.
  • If the radix is outside the range from Character.MIN_RADIX(which is 2) to Character.MAX_RADIX(which is 36) inclusive, it will default to 10 (as is the case for Integer.toString).

Example 1

Test it Now

Output:

String representation of 15 is 15

Example 2

Test it Now

Output:

String representation of 15 in radix 1 is 15

Example 3

Test it Now

Output:

String representation of 15 in radix 9 is 16

Example 4

Test it Now

Output:

String representation of 255 in radix 9 is 313

Next TopicJava BigInteger




Latest Courses