Java BigInteger toByteArray() methodThe toByteArray() method of Java BigInteger class is used to find the binary representation of this BigInteger in the form of byte array. A byte array contains the minimum number of bytes required to represent this BigInteger, including at least one sign bit, which is (ceil((this.bitLength() + 1)/8)). Syntax:Parameter:NA Returns:This method returns a byte array containing the 2's complement representation of this BigInteger. Exception:NA Note: The byte array will be in big-endian byte-order: the most significant byte is present as the 0th element. For example: 0x10,0x14 etc.Example 1Test it NowOutput: Byte array representation of 20 is: 0x14 Example 2Test it NowOutput: Byte array representation of 255 is: 0x00 0xFF Example 3Test it NowOutput: Byte array representation of 65535 is: 0x00 0xFF 0xFF Next TopicJava BigInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India