>有什么用< numpy dtype中的迹象是什么意思? [英] What do the > < signs in numpy dtype mean?
问题描述
dtype='f'
,dtype='f4'
,dtype='>f4'
,dtype'<f4'
有什么区别?
有关类型的文档中没有说明语法(但"f'是'float32'的简写);它广泛用于记录上的页面,但>
/<
在那里也无法解释.
What is the difference between dtype='f'
, dtype='f4'
, dtype='>f4'
, dtype'<f4'
?
The syntax is not explained in docs on types (except that 'f' is a shorthand for 'float32'); it is extensively used in the page on records but the meaning of >
/<
is also left unexplained in there.
经过一番实验,我发现了
After some experimentation I found out that
In [13]: a = np.array([1.0], dtype='f')
In [15]: print(a.dtype)
float32
和
In [16]: a = np.array([1.0], dtype='<f4')
In [17]: print(a.dtype)
float32
但是
In [18]: a = np.array([1.0], dtype='>f4')
In [19]: print(a.dtype)
>f4
这使我相信这些不是等效的,这可能是我对外部库所面临问题的解释.
It makes me believe those are not equivalent, which may be the explanation for issues I am facing with an external library.
推荐答案
字节序.
<
= little-endian(LSB在前)
<
= little-endian (LSB first)
>
= big-endian(MSB优先)
>
= big-endian (MSB first)
https://docs.scipy.org/doc/numpy/reference/generation/numpy.dtype.byteorder.html
这篇关于>有什么用< numpy dtype中的迹象是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!