Boolean expressions are stuff like 5>8 and stuff of the like, correct? I'm pretty sure that they're used a lot in loops, but are they used in any other functions?
A boolean expression is an expression that evaluates to True or False. They are primarily used in loop tests and if statements.
In C++, you also have bitwise logical operators that treat 1 as True and 0 as False. By using these operators on unsigned char, you can easily do things like IP masking. Boolean expressions also show up a LOT in electronics, in things called logic gates. Those are what actually make all of our computers work.
loops and if statements are conditional
the condition is a boolean statement
so 5>8 would evaluate false
and false is, of course, a boolean value
some programming languages allow either true/false or 1/0
Oh yeah, now it's all coming back to me, I used to know some stuff about this but I'd forgotten. What's the thing called with the AND/OR/XOR stuff?
logic...?
They are used in conditional statements like 5>x OR x>10
AND returns true only if both operands are true.
OR returns true if at least one operand is true.
XOR returns true if the operands are different.
NOT returns the opposite of its operand.
XOR returns FALSE if both operands are 0. XOR is basically, "if one or the other, but not both".
1 Xor 1 = 0
Oh! XOR is basically the exclusive or, and the regular OR is the inclusive OR, I learned that back in geometry. Interesting...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks