EasyManuals Logo

Sinclair QL Beginner's Guide

Sinclair QL
135 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #67 background imageLoading...
Page #67 background image
NOT (red AND square)
then for a red triangle the whole expression is true. There must be a rule in programming to make it
clear what is meant. The rule is that NOT takes precedence over AND so the interpretation:
(NOT red) AND square
is the correct one This is the same as:
NOT red AND square
To get the other interpretation you must use brackets. If you need to use a complex logical expression
it is best to use brackets and NOT if their usage naturally reflects what you want. But you can if you
wish always remove brackets by using the following laws (attributed to Augustus De Morgan)
NOT (a AND b)
is the same as
NOT a OR NOT b
NOT (a OR b)
is the same as
NOT a AND NOT b
For example:
NOT (tall AND fair) is the same as
NOT tall OR NOT fair
NOT (hungry OR thirsty) is the same as
NOT hungry AND NOT thirsty
Test this by entering
100 REMark NOT and brackets
110 PRINT "Enter two values"\"1 for TRUE or 0 for FALSE"
120 INPUT "tall "; tall
130 INPUT "fair "; fair
140 IF NOT (tall AND fair) THEN PRINT "FIRST"
150 IF NOT tall OR NOT fair THEN PRINT "SECOND"
Whatever combination of numbers you give as input, the output will always be either two words or
none, never one. This will suggest that the two compound logical expressions are equivalent.
XOR-Exclusive OR
Suppose a golf professional wanted an assistant who could either run the shop or give golf lessons. If
an applicant turned up with both abilities he might not get the job because the golf professional might
fear that such an able assistant would try to take over. He would accept a good golfer who could not
run the shop. He would also accept a poor golfer who could run the shop. This is an exclusive OR
situation: either is acceptable but not both. The following program would test applicants:
100 REMark XOR test
110 PRINT "Enter 1 for yes or 0 for no."
120 INPUT "Can you run a shop?", shop
130 INPUT "Can you teach golf?", golf
140 IF shop XOR golf THEN PRINT "Suitable"
The only combinations of answers that will cause the output "Suitable" are (0 and 1) or
(1 and 0). The rules for XOR are given below.
Able to run shop
Able to teach
Shop XOR teach
effect
FALSE
FALSE
TRUE
TRUE
FALSE
TRUE
FALSE
TRUE
FALSE
TRUE
TRUE
FALSE
No job
Gets the job
Gets the job
No job

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals