NaN [Not a Number]

NaN एक ऐसा term है जिसका इस्तमाल mathematics और computer science में होता है एक non-numeric value को describe करने के लिए.

NaN का Full-Form होता है “Not a Number.” इसका इस्तमाल एक placeholder के तोर पर भी किया जा सकता है वो भी एक expected numeric result के लिए जिसे की एक floating-point number के तोर पर define नहीं किया जा सकता है.

वैसे तो दो primary प्रकार के तरीके हैं जिससे की NaN को generate किया जा सकता है :

1) एक mathematical calculation
2) non-numeric input.

यहाँ नीचे बताये गए mathematical calculations प्रदान करता है ऐसे result जो की undefined होते हैं:

  • 0 ÷ 0
  • 0 x ∞
  • ∞ ÷ ∞

जब एक calculation में शामिल होते हैं एक character, string, या दुसरे non-numeric value, तब परिणाम में NaN भी हो सकता है. उदाहरण के लिए, 20 x “horse” कोई भी एक numeric result प्रदान नहीं करती है चूँकि 20 एक integer है और “horse” एक string होती है. एक function return कर सकता है NaN वो भी एक result के रूप में invalid input की, जो की prefer किया जाता है एक alternative के तोर पर एक program crash के लिए.

कुछ spreadsheet और database programs display करते हैं NaN या #NaN वो भी एक table cell में जब cell formula receive नहीं करता है एक valid numeric input calculation के लिए.

अलग अलग programming languages handle करती हैं NaN values वो भी अलग अलग तरीकों से. उदाहरण के लिए, JavaScript में, NaN एक property होता है global object (i.e. Number.NaN) की. वहीँ JavaScript प्रदान करता है एक isNan() function को ये check करने के लिए की क्या एक value NaN है या नहीं. वहीँ PHP इस्तमाल करती है function is_nan() को उसी कार्य के लिए. दोनों ही return करते हैं एक boolean value जो की होता है true या false.

« Back to Wiki Index