C# में Double.IsPositiveInfinity () विधि का उपयोग यह इंगित करने के लिए किया जाता है कि निर्दिष्ट संख्या सकारात्मक अनंतता का मूल्यांकन करती है या नहीं।
सिंटैक्स
वाक्य रचना इस प्रकार है -
public static bool IsPositiveInfinity (double val);
ऊपर, वैल एक डबल-सटीक फ़्लोटिंग-पॉइंट नंबर है।
उदाहरण
आइए अब एक उदाहरण देखें -
using System; public class Demo { public static void Main() { double d = 1.0/0.0; Console.WriteLine("Double Value = "+d); Console.WriteLine("HashCode of Double Value = "+d.GetHashCode()); TypeCode type = d.GetTypeCode(); Console.WriteLine("TypeCode of Double Value = "+type); Console.WriteLine("Positive Infinity? = "+Double.IsInfinity(d)); Console.WriteLine("Check whether the specified value is NaN? = "+Double.IsNaN(d)); Console.WriteLine("Does the value evaluate to negative infinity? = "+Double.IsNegativeInfinity(d)); Console.WriteLine("Does the value evaluate to positive infinity? = "+Double.IsPositiveInfinity(d)); } }
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Double Value = ∞ HashCode of Double Value = 2146435072 TypeCode of Double Value = Double Positive Infinity? = True Check whether the specified value is NaN? = False Does the value evaluate to negative infinity? = False Does the value evaluate to positive infinity? = True
उदाहरण
आइए अब एक और उदाहरण देखें -
using System; public class Demo { public static void Main() { double d = -50.0/0.0; Console.WriteLine("Double Value = "+d); Console.WriteLine("HashCode of Double Value = "+d.GetHashCode()); TypeCode type = d.GetTypeCode(); Console.WriteLine("TypeCode of Double Value = "+type); Console.WriteLine("Positive Infinity? = "+Double.IsInfinity(d)); Console.WriteLine("Check whether the specified value is NaN? = "+Double.IsNaN(d)); Console.WriteLine("Does the value evaluate to negative infinity? = "+Double.IsNegativeInfinity(d)); Console.WriteLine("Does the value evaluate to positive infinity? = "+Double.IsPositiveInfinity(d)); } }
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Double Value = -∞ HashCode of Double Value = -1048576 TypeCode of Double Value = Double Positive Infinity? = True Check whether the specified value is NaN? = False Does the value evaluate to negative infinity? = True Does the value evaluate to positive infinity? = False