float 유형에 대한 기계 제한 정보를 얻으려면 PythonNumpy에서 numpy.finfo() 메서드를 사용하십시오. 첫 번째 매개변수는 float, 즉 정보를 가져올 float 데이터 유형의 종류입니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np
min은 주어진 dtype의 최소값이고 max는 주어진 dtype의 최소값입니다.
인스턴스로 float16 유형 확인 -
a = np.finfo(np.float16(12.5))
print("Minimum of float16 type...\n",a.min)
print("Maximum of float16 type...\n",a.max) 인스턴스로 float32 유형 확인 -
b = np.finfo(np.float32(30.5))
print("\nMinimum of float32 type...\n",b.min)
print("Maximum of float32 type...\n",b.max) 인스턴스로 float 유형 확인하기 -
c = np.finfo(np.float64(55.9))
print("\nMinimum of float64 type...\n",c.min)
print("Maximum of float64 type...\n",c.max) 예시
import numpy as np
# To get the machine limits information for float types, use the numpy.finfo() method in Python Numpy
# The first parameter is the float i.e. the kind of float data type to get information about.
# Checking for float16 type with instances
# The min is the minimum value of given dtype.
# The max is the minimum value of given dtype.
a = np.finfo(np.float16(12.5))
print("Minimum of float16 type...\n",a.min)
print("Maximum of float16 type...\n",a.max)
# Checking for float32 type with instances
b = np.finfo(np.float32(30.5))
print("\nMinimum of float32 type...\n",b.min)
print("Maximum of float32 type...\n",b.max)
# Checking for float type with instances
c = np.finfo(np.float64(55.9))
print("\nMinimum of float64 type...\n",c.min)
print("Maximum of float64 type...\n",c.max) 출력
Minimum of float16 type... -65500.0 Maximum of float16 type... 65500.0 Minimum of float32 type... -3.4028235e+38 Maximum of float32 type... 3.4028235e+38 Minimum of float64 type... -1.7976931348623157e+308 Maximum of float64 type... 1.7976931348623157e+308