Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:42:46+00:00 2026-06-13T11:42:46+00:00

In the code below, I am getting a java.lang.NumberFormatException when entering large numbers ~1000000000.

  • 0

In the code below, I am getting a java.lang.NumberFormatException when entering large numbers ~1000000000. The error occurs on the second-last line -\

int integer = Integer.parseInt(split[0]);

It should work in theory since Integer type supports till 2^32-1 but it doesn’t

Scanner user_input = new Scanner(System.in);
//accept user input and convert into double
String s = user_input.next();
double number = Double.parseDouble(s);
System.out.println(number);

String answer = "";

//Split the entered number into Integer and Decimal parts
String split[] = Double.toString(number).split("\\.");
int integer = Integer.parseInt(split[0]);
int decimal = Integer.parseInt(split[1]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:42:47+00:00Added an answer on June 13, 2026 at 11:42 am

    The problem is probably because of the representation of a large double which will be in scientific notation:

    1.0E9
    

    This will mean that the split is failing, try printing out the value of the string you are parsing.

    When you call toString on a double, the format used can vary, try using DecimalFormat instead:

    new java.text.DecimalFormat("0.00000000").format(number)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting below error. java.lang.NullPointerException 11-14 16:46:59.093: E/AndroidRuntime(4064): at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:90) Using below code.
Still getting java.lang.StringIndexOutOfBoundsException: index=0 length=0 error in the code below at if (result.charAt(0) =='Y')
getting below error after i configure MQ connection factory. java.lang.ClassCastException: com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle incompatible with com.ibm.mq.jms.MQQueueConnectionFactory
I'm getting the error Exception in thread main java.lang.NumberFormatException: For input string: scores.txt at
I am getting java.lang.VerifyError.I am posting my log-file and code below. I have looked
In the following code, I am getting java.lang.InstantiationException (Below is trimmed down code that
IN JAVA CODE IN JSP as below i m getting null value for fieldnoOfRecords.
I am getting a Value cannot be null error from the code below: @Html.Label(material.ExtendedGroup)
I’m getting system error when I try to compile the code below on Visual
I'm getting this error message with the code below: class Money { public: Money(float

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.