O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System.Math

This provides a core set of mathematical functions along with two constants: the ratio of the circumference of a circle to its diameter (pi) and the natural logarithm base (e). Listing B.14 provides an example of using parts of the Math class (math.cs).

Listing B.14. Math Example
static void Main(string [] args)
{
    Console.WriteLine("Pi: {0} ", Math.PI);
    Console.WriteLine("E: {0} ", Math.E);
    Console.WriteLine("sqrt(2): {0} ", Math.Sqrt(2.0));
    Console.WriteLine("log(e): {0} ", Math.Log(Math.E));
    Console.WriteLine("cos(pi): {0} ", Math.Cos(Math.PI));
    Console.WriteLine("sin(pi): {0} ", Math.Sin(Math.PI));
    Console.WriteLine("2^5: {0} ", Math.Pow(2,5));
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required