C# Math E

Description

Math E represents the natural logarithmic base, specified by the constant, e.

Syntax

Math.E has the following syntax.


public const double E

Example

The following example compares E with the value calculated from a power series.


//from   w ww  . ja  v a  2  s .c  om
// Example for the Math.E field. 
using System;

class EField 
{
    public static void Main() 
    {
        double factorial = 1.0;
        double PS = 0.0;

        for( int n = 0; n < 90 && Math.Abs( Math.E - PS ) > 1.0E-15; n++ )
        {
            // Calculate a running factorial. 
            if( n > 0 )
                factorial *= (double)n;

            // Calculate and display the power series.
            PS += 1.0 / factorial;
            Console.WriteLine( PS);
            Console.WriteLine(Math.E - PS );
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version