C# Math Sign(Double)
Description
Math Sign(Double)
returns a value indicating the sign
of a double-precision floating-point number.
Syntax
Math.Sign(Double)
has the following syntax.
public static int Sign(
double value
)
Parameters
Math.Sign(Double)
has the following parameters.
value
- A signed number.
Returns
Math.Sign(Double)
method returns A number that indicates the sign of value, as shown in the following table.
Return value Meaning -1 value is less than zero. 0 value is equal to zero. 1
value is greater than zero.
Example
The following example demonstrates how to use the Sign(Double) method to determine the sign of a Double value and display it to the console.
using System;// ww w . ja v a 2 s .c o m
class Sample
{
public static void Main()
{
double xDouble1 = 6.0;
Console.WriteLine(Test(Math.Sign(xDouble1)));
}
public static String Test(int compare)
{
if (compare == 0)
return "equal to";
else if (compare < 0)
return "less than";
else
return "greater than";
}
}
The code above generates the following result.