G
gbgeek
I've looked around the web a bit and didn't find much luck in locating
a solution. Here the bit of code that I'm working with:
strMyValue = "";
for (double d = double.MinValue; d < double.MaxValue && numPoints <
maxPoints; d+=1.1F)
{
strMyValue = d.ToString();
//Here I hand off the string to be used by another object
}
The strangeness that I get comes in the conversion d's value to a
string. In the debug window, I see this value for d:
-1.7976931348623157E+308
After I call d.ToString(), I receive this value for strMyValue:
"-1.79769313486232E+308"
Somehow the ToString() function managed to round the last few digits
(157 becomes a 2). Normally, this wouldn't be an issue, but since I'm
on the edge of the minimum value for a double, this rounding causes the
object that I had this off to to fail. The way I see it (and I know
these are two seperate things but hang with me), if the debug window
can display a textual representation of d's value, then the ToString()
function should be able to do as good a job.
Why did I ever create this snippet? I am testing a COM object to
determine if the object is able to successfully coerce strings back
into their repective data types. Of course, since the number I'm
representing is now outside the range of a valid double due to the
rounding issue, the coercion fails.
Has anyone else had trouble with the ToString() method? I've tested
some of the other types and, to this point, only doubles have given me
any hassle.
Thanks,
Gary
a solution. Here the bit of code that I'm working with:
strMyValue = "";
for (double d = double.MinValue; d < double.MaxValue && numPoints <
maxPoints; d+=1.1F)
{
strMyValue = d.ToString();
//Here I hand off the string to be used by another object
}
The strangeness that I get comes in the conversion d's value to a
string. In the debug window, I see this value for d:
-1.7976931348623157E+308
After I call d.ToString(), I receive this value for strMyValue:
"-1.79769313486232E+308"
Somehow the ToString() function managed to round the last few digits
(157 becomes a 2). Normally, this wouldn't be an issue, but since I'm
on the edge of the minimum value for a double, this rounding causes the
object that I had this off to to fail. The way I see it (and I know
these are two seperate things but hang with me), if the debug window
can display a textual representation of d's value, then the ToString()
function should be able to do as good a job.
Why did I ever create this snippet? I am testing a COM object to
determine if the object is able to successfully coerce strings back
into their repective data types. Of course, since the number I'm
representing is now outside the range of a valid double due to the
rounding issue, the coercion fails.
Has anyone else had trouble with the ToString() method? I've tested
some of the other types and, to this point, only doubles have given me
any hassle.
Thanks,
Gary