Arithmetic
Addition (+), subtraction (-), multiplication (*), and division (/) are all defined as usual. Division also offers two special operators: x div y is the integer quotient of x and y, and x mod y is the integer remainder.
Normal arithmetic precedence rules are followed: a+b*c means a+(b*c). Parentheses may be used to clarify.
?a..b?, ?a,b,c?: Random numbers and choices
Randomly picks a value. In the first form, the value is any floating-point number in the given range (inclusive). In the second form, you list out all the values and one of them is randomly picked. The first form always operates on numbers; the second form may use strings as well.
|x|, |x,y|: Magnitude (absolute value)
The first form computes the absolute value of number. This just makes negative numbers positive; another way of looking at it is that it just computes the distance from 0 to number.
The second form computes the distance from (0,0) to (x,y) in a 2-dimensional plane.
<x,y>: Angle to a point
Computes the angle, in degrees, from the positive X axis to the line from (0,0) to (x,y), counterclockwise. (x and y may be any numbers; they need not be on-screen pixel coordinates.)
For example, <1,1> is 45, <0,1> is 90, <-1,0> is 180, and <0,-1> is 270.
As a special case, the value of <0,0> is defined to be 0. (Since a line of any angle passes through just the point (0,0), we could have chosen any value we wanted, or made it an error, but 0 makes things easier.)
Rounding to integers
Rounds x to the nearest integer, so that 1.2 becomes 1 and 1.8 becomes 2. 1.5 rounds up to 2 as well.
Chops off the fractional part of x, so that 1.2, 1.8, and 1.5 all become 1, and -1.2, -1.8, and -1.5 all become -1.
Rounds x up to the next larger integer, so that 1.2, 1.8, and 1.5 all become 2, and -1.2, -1.8, and -1.5 all become -1.
Rounds x down to the next lower integer, so that 1.2, 1.8, and 1.5 all become 1, and -1.2, -1.8, and -1.5 all become -2.
sqrt: Square root
Returns the square root of value. If value is negative, ends the program with an error.
curt: Cube root
Computes the cube root of x.
sgn: Get the sign of a number
Returns -1 if x is less than zero, 0 if x is equal to zero, or 1 if x is greater than zero.
exp: Exponential growth
Returns e raised to the power of x, where e is Euler's constant, roughly equal to 2.71828. This is the opposite of ln.
ln: Natural logarithm
Returns the natural logarithm of x. Causes an error if x is less than or equal to zero. This is the opposite of exp.
Trig functions
Returns the sine, cosine, tangent, cotangent, secant, or cosecant of angle, which must be given in degrees.
Note these identities:
Since both cosine and sine functions can be 0, the tangent, cotangent, secant, and cosecant functions can each create a division-by-zero error at the appropriate place.