数学方程和位运算? [英] mathematical equation for AND bitwise operation?

查看:93
本文介绍了数学方程和位运算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在例如左移位操作时,

5℃;< 1 = 10

10 LT;< 1 = 20

然后数学方程式可以被做,

then a mathematical equation can be made,

N'LT;< 1 = N * 2。

如果存在为左移动作的方程,

If there is an equation for a shift left operation,

则是有可能,也有

数学方程
AND操作?

mathematical equation for an AND operation?

或任何其他位运算符?

推荐答案

有是映射到每一个位运算没有直接的单人操作。但是,它们都可以通过反复的手段(或一个很长的公式)模拟。

There is no straightforward single operation that maps to every bitwise operation. However, they can all be simulated through iterative means (or one really long formula).

(a & b)

可以用来完成:

(((a/1 % 2) * (b/1 % 2)) * 1) +
(((a/2 % 2) * (b/2 % 2)) * 2) +
(((a/4 % 2) * (b/4 % 2)) * 4) +
...
(((a/n % 2) * (b/n % 2)) * n)

其中,n是2到A和B是由减一比特数。这是假定整数除法(余被丢弃)。

Where n is 2 to the number of bits that A and B are composed minus one. This assumes integer division (remainder is discarded).

这篇关于数学方程和位运算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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