This is a list of number-related commands:
Adds the two numbers x and y, and returns the result
Eg: sum 40 60 returns 100
Returns x - y.
Eg: difference 100 20 returns 80
Returns the negative of x.
Eg: minus 5 returns -5. See the note at the end of this table.
Returns the result of multiplying x by y.
Returns the result of dividing x by y
div 3 6 returns 0.5
Returns quotient x by y
quotient 15 6 returns 2
Returns the remainder after dividing x by y.
Returns x modulo y.
|
|
|
|
x | y | remainder x y | modulo x y |
|
|
|
|
14 | 5 | 4 | 4 |
|
|
|
|
-14 | 5 | -4 | 1 |
|
|
|
|
14 | -5 | 4 | -1 |
|
|
|
|
-14 | -5 | -4 | -4 |
|
|
|
|
|
This table shows the différence between modulo x y and remainder x y.
Returns the nearest whole number to the number x.
round 6.4 returns 6
Returns the integer part of the number x. integer 8.9 returns 8
integer 6.8 returns 6
Returns x raised to the power of n.
power 3 2 returns 9
Returns the square root.
Returns the logarithm of x.
Returns the exponential of x.
Returns the decimal logarithm of x.
Returns the sine of x. (x is expressed in degrees)
Returns the cosine of x. (x is expressed in degrees)
Returns the tangent of x. (x is expressed in degrees)
Returns the angle in range [0-180] which cosine is x.
Returns the angle which sine is x.
Returns the angle which tangent is x.
Returns the number π (3.141592653589793)
Returns a random integer between 0 and n - 1.
Returns a random number between 0 and 1.
Returns the absolute value (its numerical value without regard to its sign) of a number.
Sets the number of digits, it sets the precision while calculating. Some more informations:
- By default, 16 digits are allowed.
- If n is negative, the default mode is choosen.
- If n is esual to 0, all numbers are rounded to the unit.
This primitive is useful when you want to calculate with a high precision. Have a look at the example with number π
p..
Returns the number of digits allowed while calculating. By default, this value is -1.
Important : Be careful with those primitives which require two parameters!
Eg: setxy a b | If b is negative |
For example, | setxy 200 -10 |
|
|
The LOGO interpreter will carry out the operation 200-10 (ie it will subtract 10 from 200). It will therefore
conclude that there is only one parameter (190) when it requires two, and will generate an error message. To avoid
this type of problem, use the primitive “minus” to specify the negative number - setxy 200 minus
10.
This is a list of logical operators:
Returns true if b1 or b2 is true, otherwise returns false
Returns true if b1 and b2 is true, otherwise returns false
Returns the negation of b1.
- If b1 is true, returns false.
- If b1 is false, returns true.