Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OR, AND Operator

Newbie question. How to calculate the value of the formula A f B, where f - the binary function OR or AND?

like image 613
Alexry Avatar asked May 17 '10 10:05

Alexry


People also ask

What is the difference between *and and *or operators?

The *AND operator indicates that both operands (on either side of the operator) have to be true to produce a true result. The *OR operator indicates that one or the other of its operands must be true to produce a true result.

What is the or operator in R?

Moreover, logical operators allow us to change or compare the results. There are various types of operators available in R, and logical is one of them; we will talk about the OR operator. The OR is a built-in R logical operator that returns TRUE if one of the conditions is TRUE. If both conditions are FALSE, then it will return FALSE.

What is a logical operator?

It is the type of operator (*AND or *OR) that characterizes the expression as logical, not the type of operand. Operands in logical expressions can be logical variables or other expressions, such as relational expressions.

What does the or operator do in C++?

The *OR operator indicates that one or the other of its operands must be true to produce a true result. Note: Using the ampersand symbol or the vertical bar can cause problems because the symbols are not at the same code point for all code pages.


1 Answers

There is a distinction between the conditional operators && and || and the boolean operators & and |. Mainly it is a difference of precendence (which operators get evaluated first) and also the && and || are 'escaping'. This means that is a sequence such as...

cond1 && cond2 && cond3

If cond1 is false, neither cond2 or cond3 are evaluated as the code rightly assumes that no matter what their value, the expression cannot be true. Likewise...

cond1 || cond2 || cond3

If cond1 is true, neither cond2 or cond3 are evaluated as the expression must be true no matter what their value is.

The bitwise counterparts, & and | are not escaping.

Hope that helps.

like image 94
Martin Randall Avatar answered Sep 21 '22 15:09

Martin Randall