Math.E ConstantUse the Math.E constant from the System namespace. E equals 2.71828182845905.
This page was last reviewed on Sep 25, 2022.
Math.E. This is a constant value. Part of the System namespace, it is a public float value. It stores the first digits of the base of the natural logarithm.
Constant notes. Math.E lacks enough digits for many usages—many scientific programs would need more. As a constant, it is easily accessed by all C# programs.
Example. To access Math.E, use "System.Math.E" or include the using System directive at the top. The constant is encoded as a Float64 type in the Framework. Float64 has a 64-bit data space.
Note This program is not useful, but it does use the constant e. And it shows the number of digits.
using System; class Program { static void Main() { double e = Math.E; // Get E constant Console.WriteLine("--- Math.E ---"); Console.WriteLine(e); // Write E constant } }
--- Math.E --- 2.71828182845905
Discussion. Are there any practical usages of Math.E in C# programs that would be satisfied by this constant? The E constant in mathematics is used primarily for limits and derivatives.
But In programs demanding these mathematical methods, you would likely use an external numerical library rather than access Math.E.
A summary. We looked at the Math.E public double field. This field unfortunately does not contain enough significant digits for more demanding scientific applications or even puzzles.
Dot Net Perls is a collection of tested code examples. Pages are continually updated to stay current, with code correctness a top priority.
Sam Allen is passionate about computer languages. In the past, his work has been recommended by Apple and Microsoft and he has studied computers at a selective university in the United States.
This page was last updated on Sep 25, 2022 (edit).
© 2007-2023 Sam Allen.