Q(uick)BASIC Operator: IMP
Quick View
IMP Logical Operator
The logical-implication operator belongs to the family of boolean operators
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- result = expression1 boolean-operator expression2
Description/Parameter(s)
| boolean-operator | Any of the following Boolean operators: |
| NOT | Bit-wise complement |
| AND | Conjunction |
| OR | Disjunction (inclusive "or") |
| XOR | Exclusive "or" |
| EQV | Equivalence |
| IMP | Implication |
Each operator returns results as indicated in the following truth table. T is true (nonzero); F is false (zero):
| Expression1 | Expression2 | NOT | AND | OR | XOR | EQV | IMP |
| T | T | F | T | T | F | T | T |
| T | F | F | F | T | T | F | F |
| F | T | T | F | T | T | F | T |
| F | F | T | F | F | F | T | T |
- Boolean operations are performed after arithmetic and relational operations in order of precedence.
- Expressions are converted to integers or long integers before a Boolean operation is performed.
- If the expressions evaluate to 0 or -1, a Boolean operation returns 0 or -1 as the result. Because Boolean operators do bit-wise calculations, using values other than 0 for false and -1 for true may produce unexpected results.
Syntax
- result = numeric-expression1 IMP numeric-expression2
Description/Parameter(s)
The logical-implication operator, IMP, compares corresponding bits in numeric-expression1 and numeric-expression2, and then sets the corresponding bit in the result according to the following table:
| Bit in First Expression | Bit in Second Expression | Bit in Result |
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 1 |
See also:
Syntax
- result = numeric-expression1 IMP numeric-expression2
Description/Parameter(s)
The logical-implication operator, IMP, compares corresponding bits in numeric-expression1 and numeric-expression2, and then sets the corresponding bit in the result according to the following table:
| Bit in First Expression | Bit in Second Expression | Bit in Result |
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 1 |
See also: