120 likes | 301 Views
Boolean Logic. 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.
E N D
Boolean Logic 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 unary, prefix And dyadic, infix Or dyadic, infix Xor dyadic, infix
NOT Dim Flag As Boolean Flag = True Flag = Not Flag
AND Dim IsNiceWeather As Boolean Dim HaveMoney As Boolean Dim GoSkiing As Boolean GoSkiing = IsNiceWeather And HaveMoney
OR Dim GoodBand As Boolean Dim HotDate As Boolean Dim GoOut As Boolean GoOut = GoodBand Or HotDate
XOR Dim Cookie As Boolean Dim Candy As Boolean Dim MomSays As Boolean MomSays = 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 X As Double Dim Y As Integer Dim Name1 As String Dim Name2 As String Dim Result As Boolean Result = Name1 < Name2 Result = X = Y
exponentiation multiplication division (real) division (integer quotient) division (integer remainder) addition Subtraction ^ * / \ Mod + - Arithmetic Operators(review)