A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://docs.leaflabs.com/static.leaflabs.com/pub/leaflabs/maple-docs/latest/lang/cpp/boolean.html below:

Boolean Operators — Maple v0.0.12 Documentation

Boolean Operators¶

These can be used inside the condition of an if statement. Evaluate to true or false.

&& (logical and)¶

True only if both operands are true. For example:

if (digitalRead(2) == HIGH  && digitalRead(3) == HIGH) { // read two switches
  // ...
}

is true only if both inputs are high. Another example:

if (a >= 10 && a <= 20){}   // true if a is between 10 and 20

Be careful not to say 10 <= a <= 20! This won’t work the way you want. You have to separately test whether a is at least 10 using a >= 10, then test whether a is at most 20 using a <= 20, then combine the results using &&.

|| (logical or)¶

True if either operand is true. For example:

if (x > 0 || y > 0) {
  // ...
}

is true if either x or y is greater than 0.

! (logical not)¶

True if the operand is false. For example:

is true if x is false (i.e. if x is zero).

Some Advice¶

Warning

Make sure you don’t mistake the boolean AND operator && (double ampersand) for the bitwise AND operator & (single ampersand). They are entirely different beasts.

Similarly, do not confuse the boolean OR operator || (double pipe) with the bitwise OR operator | (single pipe).

The bitwise NOT operator ~ (tilde) looks much different than the boolean not operator ! (exclamation point, or “bang”, as some programmers say), but you still have to be sure which one you want.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4