FALSE is a BASIC numeric constant whose value represents the Boolean value false.
|Availability||Present in all original versions of BBC BASIC.|
|Syntax||BASIC I-V|| <num-var> = |
|Token (hex)||BASIC I-V|| |
|Description||BASIC I-V||An integer constant equal to 0, representing the value false in BASIC Boolean logic.|
|Associated keywords|| |
FALSE is a numeric constant used in BASIC to represent a false condition. In Boolean algebra all expressions (Boolean expressions) represent a condition that can be tested and found to be true or false.
WHILE all use a Boolean expression to decide which piece of code to execute next.
For instance, a Boolean expression in BASIC typically looks like
temperature >= -273.15 or
attempts%<10 AND (result% AND &18) = 0. It will evaluate to one of the constants,
FALSE is also a valid Boolean expression, and represents 'a condition that is never fulfilled'.
1 = 2 evaluates to
FALSE but takes longer to compute.
In BASIC there is no Boolean data type, as there is in some high-level languages. Integers are used instead. It was decided to define
FALSE = 0 as this is the easiest single integer to test for in 6502 machine code. The value of
TRUE follows from the identity:
TRUE = NOT FALSE
and due to the operation of
NOT, and the two's-complement arithmetic used on integers,
TRUE evaluates to -1.
All numeric values besides
FALSE are invalid in Boolean expressions. As inputs to
WHILE they happen to have the same effect as
TRUE, but they violate the law of the excluded middle:
((n = TRUE) OR (n = FALSE)) = TRUE
TRUE and -1, and
FALSE and 0, are interchangeable as they are both <numeric> expressions. But by convention
FALSE are used in BASIC code to mark that the numeric expression is being used as a Boolean value. For example in the idiom:
REPEAT ... UNTIL FALSE
meaning, repeat the code inside forever. The effect is the same as:
REPEAT ... UNTIL 0
-- beardo 22:44, 13 June 2007 (BST)