本文介绍了如何在c ++中实现AND和OR操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个任务,即iam应该在C ++中实现MIPS处理器,并且MIPS指令之一是AND,而OR则MIPS指令表示为和$ s1,$ s2, $ s3
这意味着 $ s1 = $ s2(和)$ s3
$ s2和$ s3
寄存器表示为位,,,我如何使用c ++执行AND和OR操作
I have an assignment that iam supposed to implement the MIPS processor in C++ and one of the MIPS instructions is "AND" and "OR" the MIPS instruction is represented as and $s1,$s2,$s3
which means that $s1=$s2(and)$s3
the $s2 and $s3
registers are represented into bits ,,, how can i perform the "AND" and "OR" operations using c++
推荐答案
p>在C ++中有二进制,逻辑和和或操作符。
There are both binary and logical and and or operators in 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
这篇关于如何在c ++中实现AND和OR操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!