Hi,
You should be okay if the user enters a 'e' or an 'E'. For example,
Double.valueOf("1.23456789e9").doubleValue() will return 1.23456789E9
and so will Double.valueOf("1.23456789E9").doubleValue().
Maybe I am missing something again..
Also, just a tip regarding null-proofing the blank check for the string
- you might want to check for null before trimming it - more like if (
S !=null && S.trim().length() >0 ){ .... }
-cheers,
Manish
> > Couldnt help but ask - Why go through all this to convert a string to a
> > double? You can do the same by new Double(yourString).doubleValue() or
[quoted text clipped - 9 lines]
> Most of the internal routines didn't seem to fit the bill. Lower case
> "e" was just [to me] a user-friendly allowance.
Richard F.L.R.Snashall - 09 Sep 2006 09:27 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> Maybe I am missing something again..
I was using Double.parseDouble. According to the documentation:
"static double parseDouble(String s)
Returns a new double initialized to the value represented by
the specified String, as performed by the valueOf method of class Double."
That failed to work properly when the user input "e".
> Also, just a tip regarding null-proofing the blank check for the string
> - you might want to check for null before trimming it - more like if (
> S !=null && S.trim().length() >0 ){ .... }
I'll keep that in mind.