NumPy 的 finfo(~)
方法返回有關特定 NumPy 浮點數據類型的信息。信息包括該數據類型占用的位數以及支持值的最大和最小限製。
參數
1. type
| dtype
浮點數據類型或要檢索其信息的浮點數據類型的實例。
返回值
包含關鍵信息的 <class 'numpy.finfo'>
對象,例如:
-
所提供的浮點數據類型的最小支持值
-
所提供的浮點數據類型的最大支持值
-
所提供的浮點數據類型的精度
例子
基本用法
要檢索有關 float32
數據類型的信息:
np.finfo(np.float32)
finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32)
分鍾
要檢索 float32
的最小允許值:
np.finfo(np.float32).min
-3.4028235e+38
最大限度
要檢索 float32
的最大允許值:
np.finfo(np.float32).max
3.4028235e+38
精確
要檢索 float32
的精度:
np.finfo(np.float32).precision
6
我們可以看到 float32
浮點數精確到大約 6 位小數。
相關用法
- Python BeautifulSoup find_next方法用法及代碼示例
- Python BeautifulSoup find_all_next方法用法及代碼示例
- Python BeautifulSoup find_next_sibling方法用法及代碼示例
- Python BeautifulSoup find_previous_sibling方法用法及代碼示例
- Python string find()用法及代碼示例
- Python BeautifulSoup find方法用法及代碼示例
- Python BeautifulSoup find_parent方法用法及代碼示例
- Python BeautifulSoup find_all方法用法及代碼示例
- Python BeautifulSoup find_parents方法用法及代碼示例
- Python calendar firstweekday()用法及代碼示例
- Python NumPy fill_diagonal方法用法及代碼示例
- Python filecmp.cmpfiles()用法及代碼示例
- Python fileinput.filelineno()用法及代碼示例
- Python fileinput.lineno()用法及代碼示例
- Python fileinput.input用法及代碼示例
- Python NumPy fix方法用法及代碼示例
- Python fileinput.isfirstline()用法及代碼示例
- Python fileinput.input()用法及代碼示例
- Python fileinput.filename()用法及代碼示例
- Python filter()用法及代碼示例
- Python NumPy fliplr方法用法及代碼示例
- Python dict fromkeys()用法及代碼示例
- Python frexp()用法及代碼示例
- Python functools.wraps用法及代碼示例
注:本文由純淨天空篩選整理自Arthur Yanagisawa大神的英文原創作品 NumPy | finfo method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。