TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C# Math.E Constant

This C# example demonstrates the Math.E constant in the .NET Framework. E equals 2.71828182845905.

Math.E is a constant. It is a public float value.

It stores the first digits of the base of the natural logarithm. It lacks enough digits for many usages. Some scientific programs need more.

Math.E in mscorlib:

float64(2.7182818284590451)

Example. First, to access the Math.E constant, use the fully qualified type name "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.

Double: Float64

In this example, the output is truncated from the intermediate language. The text output ends with "905" while the actual value in the Framework ends in "90451". This means the output text is not equal to the abstract binary form.

Note: This program is not useful, but it does use the constant e. And it shows the number of digits.

C# program that uses Math.E

using System;

class Program
{
    static void Main()
    {
	double e = Math.E; // Get E constant
	Console.WriteLine("--- Math.E ---");
	Console.WriteLine(e); // Write E constant
    }
}

Output

--- Math.E ---
2.71828182845905

Discussion. Are there any practical usages of Math.E in C# programs that would be satisfied by this constant? To answer this, recall that 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.

In 2004, when Google filed its IPO (initial public offering), it stated its goal was to raise one billion E dollars. You could compute this figure with the Math.E field. Puzzles use the E constant and this field is useful there too.

Compound Interest

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. But for certain contexts, it is useful.


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf