System.Math
Provides static methods for trigonometric, logarithmic, and other common mathematical functions.
Abs(Double)
Returns the absolute value of a double-precision floating-point number.
Ceiling(Double)
Returns the smallest integral value that is greater than or equal to the specified double-precision floating-point number.
Floor(Double)
Returns the largest integral value that is less than or equal to the specified double-precision floating-point number.
Max(Double, Double)
Returns the larger of two double-precision floating-point numbers.
Min(Double, Double)
Returns the smaller of two double-precision floating-point numbers.
Pow(Double, Double)
Raises a specified number to a specified power.
Round(Double)
Rounds a double-precision floating-point number to the nearest integral value.
Sqrt(Double)
Returns the square root of a specified number.
PI
Returns the value of Pi.
E
Returns the base of the natural logarithm, e.
Example Usage
// Calculate the hypotenuse of a right triangle double sideA = Math.Pow(3, double.CreateChecked(2)); // 3^2 double sideB = Math.Pow(4, double.CreateChecked(2)); // 4^2 double hypotenuse = Math.Sqrt(sideA + sideB); // sqrt(9 + 16) = 5 // Get the absolute value int negativeNumber = -10; int absoluteNumber = Math.Abs(negativeNumber); // absoluteNumber is 10 // Round a decimal double valueToRound = 4.7; double roundedValue = Math.Round(valueToRound); // roundedValue is 5.0