|,>和<在numpy数据类型中 [英] |, > and < in numpy datatype

查看:83
本文介绍了|,>和<在numpy数据类型中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常愚蠢的问题,但是我尝试使用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.

这篇关于|,&gt;和&lt;在numpy数据类型中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆