Mathematical and logical operations

Infix position

The infix positioning of the procedure names + and -, which contrasts sharply with LOGO's normal prefix syntax, also applies to the other mathematical and logical operations represented by the names * (multiply by), / (divide by), > (greater than), < (less than) and = (equals). Because of this positioning of the procedure name, you may run into problems distinguishing between the minus sign used to indicate a negative number and the minus sign used as the name of the procedure which subtracts its right hand input from its left hand input. LOGO is, in fact, usually quite smart about these things, as long as you write a space after the sign when you mean subtract and write a space before the sign and then number immediately after it when you intend a negative number. To help with the potential problem (and also to consistentize the syntax), some versions of LOGO provide alternative prefix versions of the operations under such names as plus, minus, times, divide, equal?.

Precedence

In more detail, the precedence order normally followed for the operations you are most likely to use is:
  1. negative numbers

  2. * and / (multiply and divide)

  3. + and -

  4. > and <

  5. =

  6. and, or, not

  7. the rest.


Ron Brasington
Department of Linguistic Science
The University of Reading
Reading
UK

E-mail: ron.brasington@rdg.ac.uk