3

Closed

bug in double.ToString

description

Hello,
 
I have a problem since .net MF v4.2 with the double to string method:
 
double d = 0.0100234567890123456789;
string s = d.ToString();
 
leads to the following result:
 
s = "1.234567890123438e-2" (instead of "1.00234567890123438e-2" !!!)
 
Thanks,
 
Bernhard
Closed Feb 16, 2012 at 10:18 PM by ZachLibby

comments

bebauer wrote Jan 25, 2012 at 4:38 PM

Hello,

we found a solution for this problem, what we did in .NET MF v4.0.
We changed the Devicecode\pal\TinyCrt\tinycrt.cpp file now in the .NET MF v4.2.
On line 238 we inserted the follwing code:

int num_zeros = 0;
while(dec2 < 0.1 && dec2 > -0.1 && dec2 != 0 && num_zeros < 15)
{
dec2 *= 10;
++num_zeros;
}

//create a string containing the leading zeros
char zeros[] = "0000000000000000";
zeros[num_zeros] = '\0';

Now it works!

Thanks,

Bernhard

wrote Feb 16, 2012 at 10:18 PM

Resolved with changeset 17270.