Link to home
Start Free TrialLog in
Avatar of accarvajal
accarvajal

asked on

Double parsing problems

Hi!

I have a String with a number data like  "16777645" which I need to convert to double. So I used Double.parse(sData), but double parsed like 1.6777645E7. How can I do parsing with double returns 16777645
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>but double parsed like 1.6777645E7

Why would that be a problem? That's just the form shown when you print it as as String
Avatar of accarvajal
accarvajal

ASKER

no, if my data (in my case is an ID) 16777645, next to parsing, I convert into String again so 1.6777645E7 is different than 16777645
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if my String Data "16777645" parsing to Double which results in 1.6777645E7, when converting to String again, data would be "1.6777645E7", how do I tell to user that "1.6777645E7" (showed on JTextField) is looking at field is actually "16777645" that is its ID?
You could do e.g.

field.setText("" + (long)yourDouble);
just use
Double.parseDouble(String_Variable)
or
double.parseDouble(String_Variable)

both might be correct..

hope this will help
Closer control over how the String is rendered can be achieved with NumberFormat