Convert BigInteger to specified radix
import java.math.BigInteger;
public class Main {
public static void main(String[] argv) throws Exception {
int radix = 32;
BigInteger bi = new BigInteger("vv", radix);
String s = bi.toString(radix);
System.out.println(s);
}
}
Output:
vv
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger number = new BigInteger("2008");
System.out.println("Number = " + number);
System.out.println("Binary = " + number.toString(2));
System.out.println("Octal = " + number.toString(8));
System.out.println("Hexadecimal = " + number.toString(16));
number = new BigInteger("FF", 16);
System.out.println("Number = " + number);
System.out.println("Number = " + number.toString(16));
}
}
Output:
Number = 2008
Binary = 11111011000
Octal = 3730
Hexadecimal = 7d8
Number = 255
Number = ff
Home
Java Book
Runnable examples
Java Book
Runnable examples
BigInteger:
- Create BigInteger from byte array
- Create BigInteger from string and long
- Convert BigInteger to byte array
- Convert BigInteger into binary string
- Convert BigInteger to specified radix
- Convert BigInteger to hexadecimal integer
- Convert BigInteger to integer
- Convert BigInteger to octal string
- Convert binary string to BigInteger
- Convert octal string to BigInteger
- Convert hexadecimal string to BigInteger
- Divide one BigInteger from another BigInteger
- Multiply one BigInteger to another BigInteger
- Negate a BigInteger
- Power a BigInteger
- Subtract one BigInteger from another BigInteger
- Is BigInteger Probable Prime
- Is a BigInteger Even
- Bit clear on BigInteger
- Bit flip on BigInteger
- Bit set on BigInteger
- Bit shift left on BigInteger
- Bit shift right on BigInteger
- Bit Test on BigInteger
- XOR a BigInteger from another BigInteger
- And operation on BigInteger
- Not operation on BigInteger
- Or operation on BigInteger
- andNot operation on BigInteger