Single.IsNegative() Method in C# with Examples

Single.IsNegative(Single) Method is used to return a value indicating whether the specified number evaluates to negative or not.

Syntax: public static bool IsNegative (float f);

Return Value: This method returns the true if f evaluates to Negative otherwise it returns false.

Below programs illustrate the use of Single.IsNegative() Method:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to demonstrate the
// Single.IsNegative() Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // Declaring and initializing value1
        float value1 = 1011.5615f;
  
        // using IsNegative() method
        bool value = Single.IsNegative(value1);
  
        // Displaying the result
        if (value)
            Console.WriteLine("{0} is Negative", value1);
        else
            Console.WriteLine("{0} is not Negative", value1);
    }
}

chevron_right


Output:

1011.562 is not Negative

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to demonstrate the
// Single.IsNegative() Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // Declaring and initializing value1
        float value1 = -10.651f;
  
        // using IsNegative() method
        bool value = Single.IsNegative(value1);
  
        // Displaying the result
        if (value)
            Console.WriteLine("{0} is Negative", value1);
        else
            Console.WriteLine("{0} is not Negative", value1);
    }
}

chevron_right


Output:

-10.651 is Negative

Reference:



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 contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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 contribute@geeksforgeeks.org to report any issue with the above content.