CodeWrangler
asked on
Prevent Double value being converted to N.NNNNNNE+NN in result
I have this rather simple statement:
... double.TryParse(p.ToString (), out q) ...
p.ToString() is 123400000000000000
q is 1.234E+18
q is declared as a double. I need q to be stored as '123400000000000000' because I need to package it to a web service later and the java based web service is crapping out because it does not see '1.234E+18' as a double.
... double.TryParse(p.ToString
p.ToString() is 123400000000000000
q is 1.234E+18
q is declared as a double. I need q to be stored as '123400000000000000' because I need to package it to a web service later and the java based web service is crapping out because it does not see '1.234E+18' as a double.
ASKER
ToString() does not take arguments....
Edit: 'p' is an object, actually a datarow, so a more accurate representation of the code is
p[1].ToString()
Edit: 'p' is an object, actually a datarow, so a more accurate representation of the code is
p[1].ToString()
Hi codewrangler
did the .Net through an compilation issue, when you try to give this....
Actually C# will accept the arguments, although it will not be shown in the intellisense.
did the .Net through an compilation issue, when you try to give this....
Actually C# will accept the arguments, although it will not be shown in the intellisense.
ASKER
this has not fixed the problem, but i can get your suggestion to work if i do this... :)
double.TryParse(p[1].ToStr ing().ToSt ring(Syste m.Globaliz ation.Cult ureInfo.In variantCul ture.Numbe rFormat), out q)
however, as i mentioned, the double value is still in scientific notation....
double.TryParse(p[1].ToStr
however, as i mentioned, the double value is still in scientific notation....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yeah, i was afraid of that. problem is that the class that VS2010 autogenerated for the webservice has the element strictly defined as Double. So my hands are tied on that one....
The double output is as expected.
> the java based web service is crapping out because it does not see '1.234E+18' as a double.
No, that's a string representation of the value. So either the Java service expects a numeric integer string or you are sending a string but don't format it as needed.
> .. the element strictly defined as Double.
If you want a numeric and integer output, use Int64:
Int64 i;
i = Convert.ToInt64(p);
As I guess you have no control over the Java service, perhaps you will have to modify your service to output an Int64. It should not be that difficult.
/gustav
> the java based web service is crapping out because it does not see '1.234E+18' as a double.
No, that's a string representation of the value. So either the Java service expects a numeric integer string or you are sending a string but don't format it as needed.
> .. the element strictly defined as Double.
If you want a numeric and integer output, use Int64:
Int64 i;
i = Convert.ToInt64(p);
As I guess you have no control over the Java service, perhaps you will have to modify your service to output an Int64. It should not be that difficult.
/gustav
but remember the number of digits will be constant in this case
Open in new window