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 9138531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:16:07+00:00 2026-06-17T09:16:07+00:00

Okay, I’m fairly new to java but I’m learning quickly(hopefully). So anyway here is

  • 0

Okay, I’m fairly new to java but I’m learning quickly(hopefully). So anyway here is my problem:

I have a string(For example we will use 2.9), I need to change this to either int or long or something similar that I can use to compare to another number.

As far as I know int doesn’t support decimals, I’m not sure if long does either? If not I need to know what does support decimals.

This is the error: java.lang.NumberFormatException: For input string: "2.9" with both Interger.parseInt and Long.parseLong

So any help would be appreciated!

  • 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-17T09:16:08+00:00Added an answer on June 17, 2026 at 9:16 am

    Both int and long are integer values (being long the representation of a long integer that is an integer with a higher capacity). The parsing fails because those types do not support a decimal part.

    If you were to use them and enforce a casting you’re relinquishing the decimal part of the number.

    double iAmADouble = 100 / 3;
    int iWasADouble = (int)iAmADouble; //This number turns out to be 33
    

    Use double or float instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so first off, I'm fairly new to web design. But for a project
Okay, I have GOT to be missing something totally rudimentary here. I have an
Okay i have seen TouchXML, parseXML, NSXMLDocument, NSXMLParser but i am really confused with
Okay, Now admittedly this sounds like a silly question; But, I actually have a
Okay... so I have a fairly interesting error... I declare a FileWriter called file,
okay, I know I am new to obj-c, but for all intents and purposes
Okay, so, for example, let's say I have an abstract class called Vehicle. The
Okay here's my situation. I have a php file that contains a simple form
Okay, I kinda asked this question already, but noticed that i might have not
Okay so I have a wordpress site. for example wordpress.com On it I have

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.