Single.IsNegative() Method in C# with Examples
Last Updated :
01 May, 2019
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:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
float value1 = 1011.5615f;
bool value = Single.IsNegative(value1);
if (value)
Console.WriteLine( "{0} is Negative" , value1);
else
Console.WriteLine( "{0} is not Negative" , value1);
}
}
|
Output:
1011.562 is not Negative
Example 2:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
float value1 = -10.651f;
bool value = Single.IsNegative(value1);
if (value)
Console.WriteLine( "{0} is Negative" , value1);
else
Console.WriteLine( "{0} is not Negative" , value1);
}
}
|
Output:
-10.651 is Negative
Reference:
Share your thoughts in the comments
Please Login to comment...