#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

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 comment