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 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






// C# program to demonstrate the
// MathF.Sign(Single) Method
using System;
class GFG {
    // Main Method
    static void Main(string[] args)
        // float data type
        float f1 = 746.89f;
        float f2 = -782.1247f;
        // displaying result
    // function to check whether the input
    // number is greater than zero or not
    public static String check(int r)
        if (r == 0)
            return "Equal to zero";
        else if (r < 0)
            return "Less than zero";
            return "Greater than zero";



Greater than zero
Less than zero
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.