Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
BASIC Relational Operators
◄Expressions and Operators► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Relational Operators
Relational operators are used to compare two values. The result of the
comparison is either "true" (nonzero) or "false" (zero). This result can
then be used to make a decision regarding program flow. Although BASIC
treats any nonzero value as true, true is usually represented by -1.
Operator Relation Expression
= Equality * X = Y
<> Inequality X <> Y
< Less than X < Y
> Greater than X > Y
<= Less than or equal to X <= Y
>= Greater than or equal to X >= Y
* The equal sign (=) is also used to assign a value to a variable.
Be careful using relational operators with single- and double-precision
values. Calculations may give extremely close but not identical results. In
particular, avoid testing for identity between two values. For example, the
PRINT statement in the following IF statement is not executed unless A! is
exactly equal to 0.0:
IF A! = 0.0 THEN PRINT "Exact result."
When A! is an extremely small value, for example 1.0E-23, the PRINT
statement is not executed.
In addition, a compiled program (.EXE file) may give different results
than the same program run in the QBX environment. See ◄Compiled Programs►
for more information.