Open In App

Single.IsNegative() Method in C# with Examples

Last Updated : 01 May, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




// 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);
    }
}


Output:

1011.562 is not Negative

Example 2:




// 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);
    }
}


Output:

-10.651 is Negative

Reference:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads