Less-than

From BeebWiki
Jump to: navigation, search

Less-than, <, is an inequality operator to test whether the value on the left is less than the value on the right.

<
Availability Present in all original versions of BBC BASIC.
Syntax BASIC I-V <num-var> = <numeric> < <numeric>
<num-var> = <string> < <string>
Token (hex) BASIC I-V 3C (operator)
Description BASIC I-V Compares the values of the two operands and returns TRUE if the left-hand operand is less than the right, and FALSE otherwise.
Associated keywords =, >, <=, >=, <>

Description

< evaluates the expressions on either side, and compares their values. If the value on the left is less than the one on the right, it returns the Boolean value TRUE, otherwise it returns FALSE. It is usually used as the condition of an IF statement, but it is equally valid to assign the result to a variable.

One numeric variable is less than another if it is nearer to negative infinity. If both numbers are negative, the one with the larger magnitude is less. For the definition of 'less-than' on strings, please see String collation.

It is not possible to daisy-chain (in)equality tests (for example IF bool% < X = Y THEN ...), as the Group 5 operators do not associate. Please see = for more details.

A pair of less-than signs makes the left shift operator, <<.

-- beardo 23:14, 13 June 2007 (BST)