#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

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

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 )

Connecting to %s

%d bloggers like this: