How BigInteger convert a byte array to number in Java?

Zizoo

I have this small code :

public static void main(String[] args)  {

    byte[] bytesArray = {7,34};
    BigInteger bytesTointeger= new BigInteger(bytesArray);
    System.out.println(bytesTointeger);

}

Output:1826

My question is what just happened how an array of bytes {7,34} converted into this number 1826 , what is the operation that caused this result ? like how to convert it manually

Pablo Lozano

The number 1826 is, in binary, 11100100010. If you split that in groups of 8 bits, you get the following:

00000111 00100010

Which are the numbers 7 and 34

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related