#1,101 – Mathematical Constants

For your convenience, the System.Math class provides two useful mathematical constants, as fields.

  • Math.E – base of the natural logarithm, or Euler’s Number e, with value of approximately 2.71828
  • Math.PI – ratio of circle’s circumference to its diameter π, with value of approximately 3.14159

If you need to use either of these constants in your code, you can use the corresponding field in the Math class.

            double radius = 5.0;
            double circumference = 2.0 * Math.PI * radius;

            Console.Write("Radius={0}, Circumference={1}", radius, circumference);

1101-001

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

2 Responses to #1,101 – Mathematical Constants

  1. bclayshannon says:

    What’s the point of adding a seemingly superfluous “2.0” to the mix? Shouldn’t circumference be simply:
    Math.PI * radius
    ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: