SUM num1 num2 (SUM num1 num2 num3 ...) num1 + num2
outputs the sum of its inputs.
DIFFERENCE num1 num2 num1 - num2
outputs the difference of its inputs. Minus sign means infix difference in ambiguous contexts (when preceded by a complete expression), unless it is preceded by a space and followed by a nonspace.
MINUS num - num
outputs the negative of its input. Minus sign means unary minus if it is immediately preceded by something requiring an input, or preceded by a space and followed by a nonspace. There is a difference in binding strength between the two forms:
MINUS 3 + 4 means -(3+4) - 3 + 4 means (-3)+4
PRODUCT num1 num2 (PRODUCT num1 num2 num3 ...) num1 * num2
outputs the product of its inputs.
QUOTIENT num1 num2 (QUOTIENT num) num1 / num2
outputs the quotient of its inputs. The quotient of two integers is an integer if and only if the dividend is a multiple of the divisor. (In other words, QUOTIENT 5 2 is 2.5, not 2, but QUOTIENT 4 2 is 2, not 2.0 -- it does the right thing.) With a single input, QUOTIENT outputs the reciprocal of the input.
REMAINDER num1 num2
outputs the remainder on dividing num1
by num2
; both must be
integers and the result is an integer with the same sign as num1.
MODULO num1 num2
outputs the remainder on dividing num1
by num2
; both must be
integers and the result is an integer with the same sign as num2.
INT num
outputs its input with fractional part removed, i.e., an integer with the same sign as the input, whose absolute value is the largest integer less than or equal to the absolute value of the input.
Note: Inside the computer numbers are represented in two different forms, one for integers and one for numbers with fractional parts. However, on most computers the largest number that can be represented in integer format is smaller than the largest integer that can be represented (even with exact precision) in floating-point (fraction) format. The INT operation will always output a number whose value is mathematically an integer, but if its input is very large the output may not be in integer format. In that case, operations like REMAINDER that require an integer input will not accept this number.
See section remainder
ROUND num
outputs the nearest integer to the input.
SQRT num
outputs the square root of the input, which must be nonnegative.
POWER num1 num2
outputs num1
to the num2
power. If num1 is negative, then
num2 must be an integer.
EXP num
outputs e (2.718281828+) to the input power.
LOG10 num
outputs the common logarithm of the input.
LN num
outputs the natural logarithm of the input.
SIN degrees
outputs the sine of its input, which is taken in degrees.
RADSIN radians
outputs the sine of its input, which is taken in radians.
COS degrees
outputs the cosine of its input, which is taken in degrees.
RADCOS radians
outputs the cosine of its input, which is taken in radians.
ARCTAN num (ARCTAN x y)
outputs the arctangent, in degrees, of its input. With two inputs, outputs the arctangent of y/x, if x is nonzero, or 90 or --90 depending on the sign of y, if x is zero.
RADARCTAN num (RADARCTAN x y)
outputs the arctangent, in radians, of its input. With two inputs, outputs the arctangent of y/x, if x is nonzero, or pi/2 or --pi/2 depending on the sign of y, if x is zero.
The expression 2*(RADARCTAN 0 1) can be used to get the value of pi.
ISEQ from to (library procedure)
outputs a list of the integers from FROM to TO, inclusive.
? show iseq 3 7 [3 4 5 6 7] ? show iseq 7 3 [7 6 5 4 3]
RSEQ from to count (library procedure)
outputs a list of COUNT equally spaced rational numbers between FROM and TO, inclusive.
? show rseq 3 5 9 [3 3.25 3.5 3.75 4 4.25 4.5 4.75 5] ? show rseq 3 5 5 [3 3.5 4 4.5 5]
LESSP num1 num2 LESS? num1 num2 num1 < num2
outputs TRUE if its first input is strictly less than its second.
GREATERP num1 num2 GREATER? num1 num2 num1 > num2
outputs TRUE if its first input is strictly greater than its second.
RANDOM num
outputs a random nonnegative integer less than its input, which must be an integer.
RERANDOM (RERANDOM seed)
command. Makes the results of RANDOM reproducible. Ordinarily the sequence of random numbers is different each time Logo is used. If you need the same sequence of pseudo-random numbers repeatedly, e.g. to debug a program, say RERANDOM before the first invocation of RANDOM. If you need more than one repeatable sequence, you can give RERANDOM an integer input; each possible input selects a unique sequence of numbers.
FORM num width precision
outputs a word containing a printable representation of num
, possibly
preceded by spaces (and therefore not a number for purposes of
performing arithmetic operations), with at least width
characters,
including exactly precision
digits after the decimal point. (If
precision
is 0 then there will be no decimal point in the output.)
As a debugging feature, (FORM num -1 format) will print the floating
point num
according to the C printf format
, to allow
to hex :num op form :num -1 "|%08X %08X| end
to allow finding out the exact result of floating point operations. The precise format needed may be machine-dependent.
BITAND num1 num2 (BITAND num1 num2 num3 ...)
outputs the bitwise AND of its inputs, which must be integers.
See section and
BITOR num1 num2 (BITOR num1 num2 num3 ...)
outputs the bitwise OR of its inputs, which must be integers.
See section or
BITXOR num1 num2 (BITXOR num1 num2 num3 ...)
outputs the bitwise EXCLUSIVE OR of its inputs, which must be integers.
See section or
BITNOT num
outputs the bitwise NOT of its input, which must be an integer.
See section not
ASHIFT num1 num2
outputs num1
arithmetic-shifted to the left by num2
bits. If num2
is negative, the shift is to the right with sign extension. The inputs
must be integers.
LSHIFT num1 num2
outputs num1
logical-shifted to the left by num2
bits. If num2 is
negative, the shift is to the right with zero fill. The inputs must be
integers.
Go to the first, previous, next, last section, table of contents.