B
Boz
Hi,
I am trying to use string.Format() to output the value of a double.
double da = 100000000000.99994;
double db = 100000000000.9994;
double dc = 100000000000.994;
double dd = 1000000000.99994;
Debug.WriteLine(string.Format("a={0:F10}", da));
Debug.WriteLine(string.Format("b={0:F10}", db));
Debug.WriteLine(string.Format("c={0:F10}", dc));
Debug.WriteLine(string.Format("d={0:F10}", dd));
give the result:
a=100000000001.0000000000
b=100000000000.9990000000
c=100000000000.9940000000
d=1000000000.9999400000
The problem is that a is being rounded to 100000000001 in formatting.
Stepping through the code, da is correctly reported by the debugger as
100000000000.99994
Is this a limitation of string.Format() ? Is there an alterative way
to output a double without rounding?
Boz
I am trying to use string.Format() to output the value of a double.
double da = 100000000000.99994;
double db = 100000000000.9994;
double dc = 100000000000.994;
double dd = 1000000000.99994;
Debug.WriteLine(string.Format("a={0:F10}", da));
Debug.WriteLine(string.Format("b={0:F10}", db));
Debug.WriteLine(string.Format("c={0:F10}", dc));
Debug.WriteLine(string.Format("d={0:F10}", dd));
give the result:
a=100000000001.0000000000
b=100000000000.9990000000
c=100000000000.9940000000
d=1000000000.9999400000
The problem is that a is being rounded to 100000000001 in formatting.
Stepping through the code, da is correctly reported by the debugger as
100000000000.99994
Is this a limitation of string.Format() ? Is there an alterative way
to output a double without rounding?
Boz