Python float 和 numpy float32 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16963956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between Python float and numpy float32
提问by TheMeaningfulEngineer
What is the difference between the built in floatand numpy.float32?
内置float和 有numpy.float32什么区别?
Example
例子
a = 58682.7578125
print type(a)
print a
print type(numpy.float32(a))
print numpy.float32(a)
Output:
输出:
<type 'float'>
58682.7578125
<type 'numpy.float32'>
58682.8
I've found herethat numpy.float32is:
我发现这里说numpy.float32的是:
float32 Single precision float: sign bit, 8 bits exponent, 23 bits mantissa
float32 单精度浮点数:符号位,8 位指数,23 位尾数
didn't find what the built in floatformat is.
没有找到内置float格式是什么。
采纳答案by John Zwinck
Python's standard floattype is a C double: http://docs.python.org/2/library/stdtypes.html#typesnumeric
Python 的标准float类型是 C double:http: //docs.python.org/2/library/stdtypes.html#typesnumeric
NumPy's standard numpy.floatis the same, and is also the same as numpy.float64.
NumPy 的标准numpy.float是一样的,也和numpy.float64.

