954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Converting String to Long

Hi All,
Can any one help me.When I converting String to long ,It shwoing Exponent value and throwing numberformat exception.
I want out put like this 99998900001.00.

String stotal=request.getParameter("amt");
sop( stotal);
long damount=Long.parseLong(stotal);
sop( damount);
I have given input at amt 99998900001.00

stotal= 99998900001.00
throw numberformateexception
damount = 9.9998900001E10

sakthi123
Newbie Poster
2 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

I don't believe a Long can have decimals. You may want to use Float or Double.

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 

you may later cast it to double which will give u the decimal part...

rajatC
Junior Poster
109 posts since Dec 2007
Reputation Points: 14
Solved Threads: 7
 

ie:

String s = "whatevernuber";
double d = Double.parseDouble(s);
mickinator
Junior Poster in Training
55 posts since Oct 2007
Reputation Points: 10
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You