?
Solved

Integer.parseString throws java.lang.NumberFormatException

Posted on 2004-09-14
1
Medium Priority
?
1,814 Views
Last Modified: 2008-03-06
Want to know why I get the above error in the following program for string s2. The string s1 and s2 are hex strings.

public class sample1{
public static void main(String args[])
     {
       String s1 = "6666B5C2";
       String s2 = "85EB3EC2";

       int val1 = Integer.parseInt(s1,16);
       System.out.println("The value for s1 is : " + val1);

       int val2 = Integer.parseInt(s2,16);
       System.out.println("The value for s2 is : " + val2);
     }
}

Thanks,
PK
0
Comment
Question by:pkhanna01
1 Comment
 
LVL 3

Accepted Solution

by:
KeithWatson earned 500 total points
ID: 12060744
The second number in decimal is 2,246,786,754, which is just too big to fit into a 32 bit signed int. It will need to be a maximum of 2,147,483,647 to fit.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
Make the most of your online learning experience.
Six Sigma Control Plans
Loops Section Overview

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question