toString(): This method is available in java.math.BigInteger class of Java.
Syntax:
String java.math.BigInteger.toString(int radix)
This method takes one argument of type int as its parameter. This method returns the string representation of this BigInteger in the given radix. If the radix is outside the range from Character.MIN_RADIX to Character.MAX_RADIX inclusive,it will default to 10.
Parameters: One parameter is required for this method.
radix: radix of the String representation.
Returns: String representation of this BigInteger in the given radix.
For Example:
BigInteger bigInteger = new BigInteger("1234")
int radix = 2
bigInteger.toString(radix) = > It returns 10011010010.
Approach
Java
import java.math.BigInteger;public class BigIntegertoStringRadix {public static void main(String[] args) {BigInteger bigInteger = new BigInteger("1234");int radix = 2;System.out.println(bigInteger.toString(radix));}}
Output:
10011010010
No comments:
Post a Comment