Convert BigInteger to into Binary in Java
Description
The following code shows how to convert BigInteger to into Binary.
Example
/* ww w . ja v a 2 s . c o m*/
import java.math.BigInteger;
public class Main {
public static void main(String[] argv) throws Exception {
byte[] bytes = new byte[] { (byte) 0x12, (byte) 0x0F, (byte) 0xF0 };
// Create a BigInteger using the byte array
BigInteger bi = new BigInteger(bytes);
String s = bi.toString(2);
System.out.println(s);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »