qb45advr.hlp (
Topic list)
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► ◄Relational Operators► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
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
When arithmetic and relational operators are combined in one expression, the
arithmetic operations are always done first. For example, the following
expression is true if the value of X + Y is less than the value of (T - 1)/Z:
X + Y < (T - 1) / Z
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.