
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Parse Hexadecimal String to Create BigInteger in Java
To parse the hexadecimal string to create BigInteger, use the following BigInteger constructor and set the radix as 16 for Hexadecimal.
BigInteger(String val, int radix)
This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.
In the below example, we have set the BigInteger and radix is set as 16 −
Example
import java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two; String hexStr = "290f98"; one = new BigInteger("250"); // parsing two = new BigInteger(hexStr, 16); System.out.println("Result (BigInteger) : " +one); System.out.println("Result (Parsing Hex String) : " +two); } }
Output
Result (BigInteger) : 250 Result (Parsing Hex String) : 2690968
Advertisements