Mono Class Library: System.Math Overview | Members

System.Math.Sqrt Method

Returns the square root of the specified double. [Edit]

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static double Sqrt (double d)

Parameters

d
A double . [Edit]

Returns

A double whose value is indicated as follows:

ConditionReturns
d >= 0A double containing the positive square root of d.

d < 0

d is equal to double.NegativeInfinity.

d is equal to double.NaN.

double.NaN.
d is equal to double.PositiveInfinity

double.PositiveInfinity.

[Edit]

Remarks

Documentation for this section has not yet been entered. [Edit]

Example

The following example demonstrates using the Math.Sqrt(double) method.

C# Example
using System;

public class MathSqrtExample
{

   public static void Main()
   {

      Double d1 = Math.Sqrt(16.0);
      Double d2 = Math.Sqrt(0.0);
      Double d3 = Math.Sqrt(-10.0);
      Console.WriteLine("Math.Sqrt(16.0) returns {0}", d1);
      Console.WriteLine("Math.Sqrt(0.0) returns {0}", d2);
      Console.WriteLine("Math.Sqrt(-10.0) returns {0}", d3);

   }

}

The output is

Math.Sqrt(16.0) returns 4
Math.Sqrt(0.0) returns 0
Math.Sqrt(-10.0) returns NaN

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0