Greater-than

From BeebWiki
Jump to: navigation, search

Greater-than, >, is an inequality operator to test whether the value on the left is greater than the value on the right. BASIC also prints it as a prompt to show it is waiting for instruction.

>
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 3E (operator)
Description BASIC I-V Compares the values of the two operands and returns TRUE if the left-hand operand is greater 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 greater 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 greater than another if it is nearer to positive infinity. If both numbers are negative, the one with the smaller magnitude is greater. For the definition of 'greater-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 greater-than signs makes the arithmetic right shift operator, >>. A triple greater-than sign is the logical right shift operator, >>>.

Prompt

When a greater-than sign appears on the left-hand side of the screen next to the cursor, such as

>_

it means BASIC is waiting for the user to type either:

  • a command,
  • a *command (beginning with *),
  • a statement,
  • a line of a program (a whole number followed by a statement), or
  • a VDU sequence (using CTRL)

and press the RETURN key. A program line updates the current program; any other input is processed and executed immediately.

-- beardo 21:19, 6 July 2007 (BST)