字节顺序也适用于位顺序吗? [英] Does endianness apply to bit order too?

查看:69
本文介绍了字节顺序也适用于位顺序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里没有找到具体的问题,如果重复,请指出来,我将其删除。

I haven't found a specific question here on SO, if this is a duplicate please point it out to me and I'll delete this.

真的,字节序与顺序有关系吗?

So really, does endianness have anything to do with bit order?

似乎暗示答案是否定的,而其他来源(我现在找不到,但是肯定我已经读了一些文章)暗示字节顺序是字节和位的顺序。

This seems to imply the answer is NO, while other sources (I fail to find one right now, but surely I've read some time ago some articles) imply that endianness is the order of bytes and bits.

更具体地说:在Big Endian架构中,MSB首先出现在内部任何字节,也是MSb在先吗?相反,在Little Endian系统上,LSB首先出现,LSb也是最先出现吗?

To be more specific: in a Big Endian architecture, where MSB is first, inside any byte, is also MSb first? Conversly, on Little Endian systems, where LSB is first, is LSb also first?

最后编辑:我发现表示 位顺序通常遵循与给定计算机系统的字节顺序相同的字节序

LAST I found this which says "Bit order usually follows the same endianness as the byte order for a given computer system"

推荐答案

其他响应也不完全准确。是的,内存是字节可寻址的,因此通常字节序在此停止。但是,寻址能力并不是创建定义良好的字节序的唯一方法。

The other responses are not completely accurate. Yes, memory is byte addressable, so usually endianness stops there. But addressability isn't the only way to create well defined endianness.

在C语言中,您可以定义位字段。位字段具有特定的布局;例如,第一个位字段(如果有一个位)可以存储在msb或lsb中,并且以大字节序方式跨字节边界包装位字段与以小字节序方式进行包装非常不同。因此,如果定义位字段,则可能具有位字节序。

In C, you can define bit fields. Bit fields have particular layouts; for example, the first bit field, if one bit, could be stored in either the msb or the lsb, and wrapping bit fields across byte boundaries in a big endian way is strikingly different than doing so in a little endian way. So if you define bit fields, you may have bit endianness.

但是,至少作为一个规则,这些排列方式与编译器的关系比体系结构更多

But how these are arranged would have more to do with the compiler than the architecture, at least as a rule.

这篇关于字节顺序也适用于位顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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