对它们产生的数字进行这些位运算之间是否存在关系

Is there a relationship between doing these bit operations on the numbers they produce

大家好,我是大学二年级学生,我对使用位和按位运算还很陌生。当我得到 3 (0011) 的二进制并将其反转 (1100) 然后将其右移时,我得到 (0110) 和 6 作为十进制数。如果我用 2 做这个,我得到 2。我想知道是否有某种通用关系可以找到 n 对它进行这 2 个操作会变成什么,因为我认为这可能是我的一个家庭作业问题的关键。

还有没有人有很好的资源来学习简单的按位运算和一般性质的小学生

When I got the binary of 3 (0011), and reversed it (1100) and then shifted it right I get (0110) and 6 as the decimal number.

  1. 你假设一个4位数字,如果有16位或32位数字系统呢?您的结果将相应改变。

  2. 右移有两种操作,无符号右移和有符号右移。似乎您执行了无符号右移,因为有符号右移将根据符号替换位。如果是负数(最高位为1),所有被替换的位都为1,否则为0。

I was wondering if there was some generic relationship to find what n would become doing those 2 operations on it.

这个说法的答案是,完全不同。

Also does anyone have a good resource to learn about simple bitwise operations and properties in general for a school kid

幸运的是,我最近才写了一篇关于 Number System and Bit operations 的博客。