Numbers are another kind of object or data on which Logo commands operate. A number can be an integer, such as 3 or 26; a decimal number, such as 2.14 or 57.86, or a number in exponential notation, such as 3.62E3 or 1.0E-2. Valid numbers in Logo can consist of any combination of the digits 0 through 9, a decimal point, the characters + or -, and the letter E when indicating exponential notation.
Logo reads a minus sign preceding a number as indicating a negative number. However, if there is a space between the minus sign and the number, Logo reads it as the subtraction operator.
Logo accurately performs calculations and mathematical operations on numbers in the range of 1E-38 and 1E38. All calculations in Logo have a precision of six digits.
Logo floating point calculations are accurate to six significant digits, but when Logo first loads, decimal numbers are rounded to display only two decimal places. You can display more or fewer digits by changing the value of the system name PRECISION.
235 * 2.543
? MAKE "PRECISION 4
? 3.25 * 2.543
? MAKE "PRECISION 8
The procedure PRECISION needs a number between 1 and 7 as its first input.
Once you have changed the value of PRECISION, it maintains the new value until you change it again or exit Logo.
Logo expresses numbers in the range between 1E-6 and 1E6 in decimal notation. Numbers outside that range are converted to scientific notation.
Logo has a wide variety of commands or primitives that deal with numbers, including traditional arithmetic operators as well as trigonometric, logarithmic, and other mathematical functions. All Logo numeric commands can be expressed with the primitive name followed by the number(s) on which it operates. For example:
? COS 90
In addition, the arithmetic operators can be used as infix operators as they are traditionally, coming between the numbers on which they operate. For example:
? 10.5 * 11.33
When there is more than one arithmetic operation in a Logo line they are evaluated in the standard order of mathematical hierarchy, as follows:
|1||-||(unary minus indicating a negative number)|
|2||*, /||(multiply and divide)|
|3||+, -||(add and subtract)|
|4||other math operations|
|5||<, >, <=, >=||(comparative functions)|
Parentheses or other delimiters can be used to change the order of operation. See the section on Syntax for a full explanation of the order in which Logo evaluates its commands and how to change it.
Logo infix operators are :
Other mathematical operations include: