- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create BigInteger from byte array in Java
BigInteger class provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.
Let’s say the following is our byte array −
byte[] arr = new byte[] { 0x1, 0x00, 0x00 };
We will now convert them to BigInteger −
BigInteger bInteger = new BigInteger(arr);
The following is an example that creates BigInteger from a byte array in Java.
Example
import java.math.BigInteger; public class Demo { public static void main(String[] argv) throws Exception { byte[] arr = new byte[] { 0x1, 0x00, 0x00 }; BigInteger bInteger = new BigInteger(arr); System.out.println(bInteger); } }
Output
65536
Advertisements