# TRUE

TRUE is a BASIC numeric constant whose value represents the Boolean value true.

 Availability Present in all original versions of BBC BASIC. Syntax BASIC I-V = `TRUE` Token (hex) BASIC I-V `B9` (rvalue) Description BASIC I-V An integer constant equal to -1, representing the value true in BASIC Boolean logic. Associated keywords `FALSE`

## Description

`TRUE` is a numeric constant used in BASIC to represent a true condition. In Boolean algebra all expressions (Boolean expressions) represent a condition that can be tested and found to be true or false. `IF`, `UNTIL` and `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, `TRUE` or `FALSE`.

`TRUE` is also a valid Boolean expression, and represents 'a condition that is always fulfilled'. `1 = 1` evaluates to `TRUE` 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 `TRUE` and `FALSE` are invalid in Boolean expressions. As inputs to `IF`, `UNTIL` and `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`

Therefore only `TRUE` and `FALSE` work correctly as Boolean operands to `AND`, `OR` and `NOT`, as these three are always 'bitwise' operators.

Syntactically speaking, `TRUE` and -1, and `FALSE` and 0, are interchangeable as they are both <numeric> expressions. But by convention `TRUE` and `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 TRUE```

meaning, run the code inside the loop only once. The effect is the same as:

```REPEAT
...
UNTIL -1```

-- beardo 22:46, 13 June 2007 (BST)