左移(理由问题) [英] left shifts (rationale question)

查看:76
本文介绍了左移(理由问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我最近遇到了一种情况,我没有特别调用UB

知道我做了它。是的,人类,我知道。


究竟是什么/不允许转移是相同的宽度

数据类型正在转移?此外,对于大多数常见平台(哦,

好​​吧,x86),可以在汇编级别进行,不是吗? (如果

操作码允许它,我想这也是我的问题。)

So I recently ran into a situation where I invoked UB without specifically
knowing I did it. Yes, human, I know.

What exactly is/was the rationale for not allowing shifts to be the same width
of the datatype one is shifting? Also, for most common platforms (oh,
alright, x86), it''s okay to do at the assembly level, isn''t it? (provided the
opcodes allow it, I guess that''s my question as well).

推荐答案

Christopher Layne写道:
Christopher Layne wrote:

所以我最近遇到了一种情况,我没有特别调用UB

知道我做到了。是的,人类,我知道。


究竟是什么/不允许转移是相同的宽度

数据类型正在转移?此外,对于大多数常见平台(哦,

好​​吧,x86),可以在汇编级别进行,不是吗? (如果

操作码允许它,我想这也是我的问题)。
So I recently ran into a situation where I invoked UB without specifically
knowing I did it. Yes, human, I know.

What exactly is/was the rationale for not allowing shifts to be the same width
of the datatype one is shifting? Also, for most common platforms (oh,
alright, x86), it''s okay to do at the assembly level, isn''t it? (provided the
opcodes allow it, I guess that''s my question as well).



不,对于某些常见平台,例如x86,这是不合适的,而且'

为什么呢''不允许。

No, it''s not okay for some common platforms, such as x86, and that''s
why it''s not allowed.


文章< 11 ************ @ news-west.n>,

Christopher Layne< cl **** @ com.anodizedwrote:
In article <11************@news-west.n>,
Christopher Layne <cl****@com.anodizedwrote:

>不允许转班的理由究竟是什么?是一个正在转移的数据类型的宽度相同?
>What exactly is/was the rationale for not allowing shifts to be the same width
of the datatype one is shifting?



最近我们经历了这个,上周左右:


上面有很多常见的处理器

移位计数的位被忽略,因此使用等于单词

宽度的移位计数等于在这些处理器上使用移位计数0。


如果不是这样的话,处理器可能需要很长时间才能完成移位0x7fffffff位...

-

原型是其克隆的超类型。 - maplesoft

We went through this pretty recently, last week or so:

There are a number of common processors where the upper bits of the
shift count are ignored, so using a shift count equal to the word
width is equivilent to using a shift count of 0 on those processors.

If things were otherwise, it could take a long time for a processor
to finish shifting by 0x7fffffff bits...
--
Prototypes are supertypes of their clones. -- maplesoft


Christopher Layne写道:
Christopher Layne wrote:

所以我最近遇到了一个我没有调用UB的情况特别是

知道我做到了。是的,人类,我知道。


究竟是什么/不允许转移是相同的宽度

数据类型正在转移?此外,对于大多数常见平台(哦,

好​​吧,x86),可以在汇编级别进行,不是吗? (如果

操作码允许它,我想这也是我的问题)。
So I recently ran into a situation where I invoked UB without specifically
knowing I did it. Yes, human, I know.

What exactly is/was the rationale for not allowing shifts to be the same width
of the datatype one is shifting? Also, for most common platforms (oh,
alright, x86), it''s okay to do at the assembly level, isn''t it? (provided the
opcodes allow it, I guess that''s my question as well).



特别是32位x86处理器在

移位操作期间忽略高27位。只考虑低5位

,因为移位32位值的最大值为31.

Particularly the 32 bit x86 processors ignore the upper 27 bits during
shift operations. Only the lower 5 bits are taken into consideration
since the maximum sane value for shifting a 32 bit value is 31.


这篇关于左移(理由问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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