Single.IsNegative(Single) Method is used to return a value indicating whether the specified number evaluates to negative or not.
csharp
csharp
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:
Example 2:
1011.562 is not Negative
// 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:
Reference:
-10.651 is Negative