|,>和<在numpy数据类型中 [英] |, > and < in numpy datatype
问题描述
这可能是一个非常愚蠢的问题,但是我尝试使用Google搜索类似less and greater signs in data type of numpy
的关键字,但没有找到参考.
This could be a very silly question but I tried to google keywords like less and greater signs in data type of numpy
and found no reference.
在numpy
的 doc 中,
x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
输出
array([(1.0, 2), (3.0, 4)],
dtype=[('x', '<f8'), ('y', '<i4')])
但是在我的PC上,输出是
But on my PC, the output is
array([(1.0, 2), (3.0, 4)],
dtype=[('x', '>f8'), ('y', '>i4')])
dtype
中的<
和>
是什么意思,为什么会有区别?
What do <
and >
in the dtype
mean and why there is the difference?
推荐答案
关键字<
和>
代表参考文献中的该页面为您提供了所有您需要的有关numpy的信息,但作为摘要:
The keywords <
and >
stand for byte ordering, aka endianness. It is the order in which bytes from numbers are stored (when numbers are compossed of more than 1 byte, e.g. int16, int32, float32...). This page from the reference gives you all the information you need about it in numpy, but as a summary:
-
|
:它没有字节顺序,因为它是多余的(在单字节数字或字符串上)
|
: it doesn't have a byte order because is redundant (on single byte numbers or strings)
<
:小尾数
>
:大端
正如@tobias_k和@RobertKern指出的那样,默认字节序(如果未指定)取决于系统.
As @tobias_k and @RobertKern pointed out, the default endianess, if not specified, is system dependant.
这篇关于|,>和<在numpy数据类型中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!