How to specify exponential constants in C#?

Kevin Boyd picture Kevin Boyd · Dec 3, 2010 · Viewed 9.7k times · Source

I've got some C code that defines a exponential number as a constant. How do I write this in C#?

    double TOL = 1.E-8d;
    double TOL2 = 1.E - 8;

Answer

please delete me picture please delete me · Dec 3, 2010

If there are no numbers after the decimal, you don't include the point. Same as in C/C++/etc. So:

double TOL= 1E-8;
double TOL2 = 1E-8;

Or maybe, for a different value:

double TOL = 1.5E-8;

This is in the spec, section 2.4.4.3:

http://msdn.microsoft.com/en-us/library/ms228593.aspx