![]()
A number that indicates the sign of value, as shown in the following table.
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.
Type Reason ArithmeticException value is equal to double.NaN.
The following example demonstrates using the Math.Sign(sbyte)(double) method.
C# Example
using System;
public class MathSignExample
{
public static void Main()
{
Double d1 = Math.Sign(4.4);
Double d2 = Math.Sign(0.0);
Double d3 = Math.Sign(-4.5);
Console.WriteLine("Math.Sign(4.4) returns {0}", d1);
Console.WriteLine("Math.Sign(0.0) returns {0}", d2);
Console.WriteLine("Math.Sign(-4.5) returns {0}", d3);
}
}
The output is
Math.Sign(4.4) returns 1