首页javabigintegerJava Data Type - 如何从字节数组创建BigInteger

Java Data Type - 如何从字节数组创建BigInteger

我们想知道如何从字节数组创建BigInteger。
import java.math.BigInteger;

public class Main {
  public static void main(String[] argv) throws Exception {
    // A negative value
    byte[] bytes = new byte[] { (byte) 0xFF, 0x00, 0x00 }; // -65536
    // A positive value
    bytes = new byte[] { 0x1, 0x00, 0x00 }; // 65536
    BigInteger bi = new BigInteger(bytes);
  }
}