如何在C++中实现AND和OR操作

Sha*_*adi 1 c++ mips instructions

我有我应该执行在C MIPS处理器++和的MIPS指令是一个"AND"和"OR" MIPS指令被表示赋值为and $s1,$s2,$s3这意味着$s1=$s2(and)$s3$s2 and $s3寄存器被表示成比特,,,如何能我使用C++执行"AND"和"OR"操作?

Pup*_*ppy 6

在C++中有二进制和逻辑和和或运算符.

int a, b = 1;

int x = a | b; // binary OR
int x = a & b; // binary AND
bool x = a || b; // boolean OR
bool x = a && b; // boolean AND
Run Code Online (Sandbox Code Playgroud)

  • 通过*binary*,他的意思是*bitwise*(http://en.wikipedia.org/wiki/Bitwise_operation).按位布尔AND/OR/NOT运算符在字操作数上逐位工作.逻辑运算符用于`bool`操作数. (2认同)