April 2002
Intermediate to advanced
1024 pages
23h 26m
English
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).
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));
}
|