C# | Math.Sign() Method Last Updated : 31 Jan, 2019 Comments Improve Suggest changes Like Article Like Report In C#, Sign() is a math class method which returns an integer that specify the sign of the number. This method can be overloaded by changing the data type of the passed arguments as follows: Math.Sign(Decimal): Returns the integer that specifies the sign of a decimal number. Math.Sign(Double): Returns the integer that specifies the sign of a double-precision floating-point number. Math.Sign(Int16): Returns the integer that specifies the sign of a 16-bit signed integer. Here Int16 is short data type Math.Sign(Int32): Returns the integer that specifies the sign of a 32-bit signed integer. Here Int32 is int data type. Math.Sign(Int64): Returns the integer that specifies the sign of a 64-bit signed integer. Here Int64 is long data type. Math.Sign(SByte): Returns the integer that specifies the sign of an 8-bit signed integer. Math.Sign(Single): Returns the integer that specifies the sign of a single-precision floating-point number. Here single is float data type. Common Syntax for all above methods: public static int Sign(data_type value) Parameter: This method takes a single parameter in the form of either bytes, int, double, sbyte, etc. Return type : This method returns the value of type System.Int32 as per following mentioned conditions: Return Value Condition: 0 If value is equal to zero 1 If value is greater than zero -1 If value is lesser than zero Example: CSHARP // C# program to demonstrate the // Math.Sign() method using System; class GFG { // Main Method static void Main(string[] args) { // Decimal data type Decimal de = 150M; // Double data type Double d = 34.5432d; // Int16 data type short sh = 0; // Int32 data type int i = -5678; // Int64 data type long l = 598964564; // SByte data type sbyte sb = -34; // float data type float f = 56.89f; // displaying result Console.WriteLine("Decimal: " + de + " " + check(Math.Sign(de))); Console.WriteLine("Double: " + d + " " + check(Math.Sign(d))); Console.WriteLine("Int16: " + sh + " " + check(Math.Sign(sh))); Console.WriteLine("Int32: " + i + " " + check(Math.Sign(i))); Console.WriteLine("Int64: " + l + " " + check(Math.Sign(l))); Console.WriteLine("SByte: " + sb + " " + check(Math.Sign(sb))); Console.WriteLine("Single: " + f + " " + check(Math.Sign(f))); } // function to check whether the input // number is greater than zero or not public static String check(int compare) { if (compare == 0) return "equal to zero"; else if (compare < 0) return "less than zero"; else return "greater than zero"; } } Output: Decimal: 150 greater than zero Double: 34.5432 greater than zero Int16: 0 equal to zero Int32: -5678 less than zero Int64: 598964564 greater than zero SByte: -34 less than zero Single: 56.89 greater than zero Comment More infoAdvertise with us Next Article C# | Math.Sign() Method A alpha_786 Follow Improve Article Tags : Misc C# CSharp-method CSharp-Math Practice Tags : Misc Similar Reads C# | Math.Sqrt() Method In C#, Math.Sqrt() is a Math class method which is used to calculate the square root of the specified number. Sqrt is a slower computation. It can be cached for a performance boost. Syntax: public static double Sqrt(double d) Parameter: d: Number whose square root is to be calculated and type of thi 3 min read Javascript Math sign() Method The Math.sign() is a built-in method in JavaScript and is used to know the sign of a number, indicating whether the number specified is negative or positive.Syntax:Math.sign(number)Parameters:This method accepts a single parameter number which represents the number whose sign you want to know. Retur 2 min read C# | Math.Abs() Method | Set - 2 C# | Math.Abs() Method | Set â 1 In C#, Abs() is a Math class method which is used to return the absolute value of a specified number. This method can be overload by passing the different type of parameters to it. There are total 7 methods in its overload list. Math.Abs(Decimal) Math.Abs(Double) Mat 3 min read C# | Math.Abs() Method | Set - 1 In C#, Abs() is a Math class method which is used to return the absolute value of a specified number. This method can be overload by passing the different type of parameters to it. Math.Abs(Decimal) Math.Abs(Double) Math.Abs(Int16) Math.Abs(Int32) Math.Abs(Int64) Math.Abs(SByte) Math.Abs(Single) Mat 4 min read MathF.Sign() Method in C# with Examples In C#, MathF.Sign(Single) is a MathF class method which returns an integer that specify the sign of the number. Syntax: public static int Sign (float x); Here, x is the required single precision floating-point number whose sign has to be calculated. Return Type: This method returns the value of type 1 min read Like