I need to convert a Java BigInteger instance to its value in bytes. From the API, I get this method toByteArray()
, that returns a byte[] containing the two's-complement representation of this BigInteger.
Since all my numbers are positive 128 bits (16 bytes) integer, I don't need the 2's-complement form that give me 128 bits + sign bit (129 bits)...
Is there a way to get the standard (without the 2's-complement form) representation directly from a BigInteger?
If not, how can I right shift the whole byte[17] array to lose the sign bit in order to get a byte[16] array?
<<<
operator in Java. – Access