Boolean Logical Operators Comparison Operators Truth tables Boolean

Boolean Logical Operators Comparison Operators Truth tables

Boolean Logic • The Boolean values (named after mathematician George Boole) are TRUE and FALSE. • They can be established in a number of ways: – Assertion – Boolean Expression – Comparison

Assertion To assert means to state. VB example: Dim Flag As Boolean Flag = True

Boolean Expression Logical operators can be used to construct Boolean expressions from Boolean values. The operands (arguments) must be Boolean. Not And Or Xor unary, prefix dyadic, infix

NOT Dim Flag As Boolean Flag = True Flag = Not Flag

AND Dim Is. Nice. Weather As Boolean Dim Have. Money As Boolean Dim Go. Skiing As Boolean Go. Skiing = Is. Nice. Weather And Have. Money

OR Dim Good. Band As Boolean Dim Hot. Date As Boolean Dim Go. Out As Boolean Go. Out = Good. Band Or Hot. Date

XOR Dim Cookie As Boolean Dim Candy As Boolean Dim Mom. Says As Boolean Mom. Says = Cookie Xor Candy

Comparison (= <> <= >= > <) Comparison Operators are used to establish relationships between Boolean values. All operators are dyadic, infix. Their arguments can be of any data type, but must be similar, i. e. both Boolean, both numeric, both String.

Comparison (= <> <= >= > <) Dim Dim Dim X As Double Y As Integer Name 1 As String Name 2 As String Result As Boolean Result = Name 1 < Name 2 Result = X = Y

Arithmetic Operators (review) • • exponentiation multiplication division (real) division (integer quotient) division (integer remainder) addition Subtraction ^ * / Mod + -

Other Operators (in order of precedence) Concatenation Comparison Logical Assignment &, + = <> <= >= > < Not And Or Xor =
- Slides: 12