I have one problem related to double data type .
dou=0.0000454444when i convert this to string it shows the value in exponential like this
messagebox.show(dou.ToString)
it shows the value in 4.5 e-4 in exponential .
Value is changing in run time even i do not cross the precision of double .I want to be my answer in double format .
Anyone know this problem please help me .I have applied all things.
AlanPosted Aug 12, 2008, 7:27 AM
The approach suggested by Sen M should work fine. In fact,if you increase the number of #'s to 15, it should suppress exponential format for any decimal number:
string format = "0.###############";
double dou = 0.0000454444;
MessageBox.Show(dou.ToString(format));
If you don't do this, then the ToString() method uses the "G" format by default which displays double precision numbers in exponential format if their absolute value is 0.00001 or less, as Manish implied.
Blocked AccountPosted Aug 12, 2008, 6:22 AM
if u decrease one zero after the decimal then this problem be resolved.
otherwise it will give the result in the exponential format.
Manoj RawatPosted Aug 12, 2008, 6:01 AM
i have a prolem with zero which is coming after decimal like this 0.00004 when i show this value through message box it shows the value in exponential format .i do not want answer in exponential form don;t change the format have u any idea related to this
SenPosted Aug 12, 2008, 5:17 AM
string str = doubleValue.ToString(formatString);
string str = doubleValue.ToString("0.############");