Boolean: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:


{{Template:RelationalTable}}
{{Template:RelationalTable}}
* When evaluating a True value, an IF value < 0 statement is NOT necessary for return values not 0.
<center>''' Truth table of the BASIC Logical Operators:'''</center>
{{Template:LogicalTruthTable}}
<center>'''Boolean Conditional Operators:'''</center>
* [[AND (boolean)|AND]] can be used to add extra conditions to a boolean statement evaluation. Both must be True.
* [[OR (boolean)|OR]] can be used to add alternate conditions to a boolean statement evaluation. One must be True.
* Parenthesis are allowed inside of boolean statements to clarify an evaluation.
* '''Note that Basic returns -1 for True and 0 for False.'''
''Example 1:'' Using 2 different boolean evaluations to determine a leap year.

Revision as of 18:51, 18 April 2022

Boolean statements are numerical evaluations that return True (-1 or NOT 0) or False (0) values that can be used in other calculations.


Basic Returns:
  • True evaluations return -1. NOT 0 = -1 in Basic. Can be used to increment a value.
  • For positive True results, subtract it, multiply it by a negative value or use ABS.
  • False evaluations return 0. Watch out for "Division by 0" errors!


Template:RelationalTable


  • When evaluating a True value, an IF value < 0 statement is NOT necessary for return values not 0.


Truth table of the BASIC Logical Operators:

Template:LogicalTruthTable


Boolean Conditional Operators:
  • AND can be used to add extra conditions to a boolean statement evaluation. Both must be True.
  • OR can be used to add alternate conditions to a boolean statement evaluation. One must be True.
  • Parenthesis are allowed inside of boolean statements to clarify an evaluation.
  • Note that Basic returns -1 for True and 0 for False.


Example 1: Using 2 different boolean evaluations to determine a leap year.