- Trending Categories
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
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
- Related Articles
- Parse Octal string to create BigInteger in Java
- Parse decimal string to create BigInteger in Java
- Create BigInteger via string in Java
- Parse and format to hexadecimal in Java
- Create BigInteger from byte array in Java
- Create BigInteger via long type variable in Java
- Multiply one BigInteger to another BigInteger in Java
- Parse a string to a Boolean object in Java
- Parse string date value input in Java
- Java Program to create random BigInteger within a given range
- Parse string date time value input in Java
- Subtract one BigInteger from another BigInteger in Java
- Divide one BigInteger from another BigInteger in Java
- How to parse a JSON string using Streaming API in Java?
- Java Program to parse string date value with default format

Advertisements