Convert binary string to BigInteger
import java.math.BigInteger;
import java.util.Arrays;
public class Main {
public static void main(String[] argv) throws Exception {
BigInteger bi = new BigInteger("100101000111111110000", 2);
byte[] bytes = bi.toByteArray();
System.out.println(Arrays.toString(bytes));
}
}
Output:
[18, -113, -16]
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