home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG031.ARK / TBASIC.15 < prev    next >
Text File  |  1984-04-29  |  1KB  |  73 lines

  1. Logical Operators:
  2.  
  3. OR, AND, and NOT are used as logical operators in IF statements.
  4. OR and AND operate on the logical expressions between which
  5. they are placed, while NOT operates on the logical expression
  6. following it.  Remember that the value of a logical expression
  7. must be either -1 (true) or 0 (false).
  8.  
  9. OR
  10. When OR is placed between two logical expressions, the total
  11. expression is true if either or both of the two logical expressions
  12. are true.
  13.  
  14. AND
  15. When AND is placed between two logical expressions, the total
  16. expression is true if and only if both of the two logical
  17. expressions are true.
  18.  
  19. NOT
  20. When NOT is placed before a logical expression, the total
  21. expression is true if the logical expression is false,
  22. and the total expression is false if the logical expression
  23. is true.
  24.  
  25. Below are truth tables for the three logical operators, where
  26. T stands for TRUE (-1), F stands for FALSE (0),
  27. and A and B are logical expressions:
  28.  
  29.     A    B    A OR B    A AND B    NOT A
  30.  
  31.     F    F      F          F         T
  32.     F    T      T          F         T
  33.     T    F      T          F         F
  34.     T    T      T          T         F
  35.  
  36. Examples:
  37.  
  38. 0 AND 1 equals 0
  39. 1 AND 1 equals 1
  40. 2 AND 1 equals 0
  41. 2 AND 3 equals 2
  42.  
  43. 0 OR 1 equals 1
  44. 1 OR 1 equals 1
  45. 2 OR 1 equals 3
  46. 2 OR 3 equals 3
  47.  
  48. NOT 0 equals -1
  49. NOT -1 equals 0
  50. NOT 1 equals -2
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.                 15
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.