पूर्णांक प्रकारों के लिए मशीन की सीमा की जानकारी प्राप्त करने के लिए, PythonNumpy में numpy.iinfo () विधि का उपयोग करें। पहला पैरामीटर int_type है यानी जानकारी प्राप्त करने के लिए पूर्णांक डेटा प्रकार का प्रकार।
कदम
सबसे पहले, आवश्यक पुस्तकालय आयात करें -
import numpy as np
न्यूनतम दिए गए dtype का न्यूनतम मान है और अधिकतम दिए गए dtype का न्यूनतम मान है।
int16 प्रकार की जांच -
a = np.iinfo(np.int16)
print("Minimum of int16 type...\n",a.min)
print("Maximum of int16 type...\n",a.max) int32 प्रकार की जांच -
b = np.iinfo(np.int32)
print("\nMinimum of int32 type...\n",b.min)
print("Maximum of int32 type...\n",b.max) int64 प्रकार के लिए जाँच -
c = np.iinfo(np.int64)
print("\nMinimum of int64 type...\n",c.min)
print("Maximum of int64 type...\n",c.max) उदाहरण
import numpy as np
# To get the machine limits information for integer types, use the numpy.iinfo() method in Python Numpy
# The first parameter is the int_type i.e. the kind of integer data type to get information about.
# Checking for int16 type
# The min is the minimum value of given dtype.
# The max is the minimum value of given dtype.
a = np.iinfo(np.int16)
print("Minimum of int16 type...\n",a.min)
print("Maximum of int16 type...\n",a.max)
# Checking for int32 type
b = np.iinfo(np.int32)
print("\nMinimum of int32 type...\n",b.min)
print("Maximum of int32 type...\n",b.max)
# Checking for int64 type
c = np.iinfo(np.int64)
print("\nMinimum of int64 type...\n",c.min)
print("Maximum of int64 type...\n",c.max) आउटपुट
Minimum of int16 type... -32768 Maximum of int16 type... 32767 Minimum of int32 type... -2147483648 Maximum of int32 type... 2147483647 Minimum of int64 type... -9223372036854775808 Maximum of int64 type... 9223372036854775807 Result... <class 'numpy.complex128'>