C# Math Sign(SByte)
Description
Math Sign(SByte)
returns a value indicating the sign
of an 8-bit signed integer.
Syntax
Math.Sign(SByte)
has the following syntax.
[CLSCompliantAttribute(false)]
public static int Sign(
sbyte value
)
Parameters
Math.Sign(SByte)
has the following parameters.
value
- A signed number.
Returns
Math.Sign(SByte)
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(SByte) method to determine the sign of an SByte value and display it to the console.
using System;/* ww w.j a v a2 s . co m*/
class Sample
{
public static void Main()
{
sbyte xSbyte1 = -101;
Console.WriteLine(Test(Math.Sign(xSbyte1)));
}
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.