4.5 Math commands
There are the commands to use the AMMP math routines. The commands support the VAR type that combines the possibility to use variable names and float/integer constant. You must remember that 1 and 1.0 constants don't have the same meaning: the first one is an integer constant and the second one is a floating point constant.
Arithmetic sum between two terms.
Parameters: | ||
Var1 | First addendum. If it's a variable name, the result is stored in it. | |
Var2 | Second addendum. |
Return message:
Result of the arithmetic operation.
Example:
ADD a 1;
Cosine trigonometric function.
Parameters: | ||
Var | Angle in radians. |
Return message:
Result of the trigonometric function.
Example:
COS 0.5;
Arithmetic division between two terms.
Parameters: | ||
Var1 | Dividend. If it's a variable name, the result (quotient) is stored in it. | |
Var2 | Divisor. |
Return message:
Result of the arithmetic operation.
Example:
DIV 1.0 3.0;
Round down to an integer.
Parameters: | ||
Var | Dividend. If it's a variable name, the result is stored in it. |
Return message:
Result of the arithmetic operation.
Example:
FIX 1.5;
See also:
None.
Get the serial number of the specified atom number.
Parameters: | ||
Var | Variable name in which the serial number is stored. | |
AtmNum | Atom number. |
Return message:
Serial number.
Example:
INDEX n 10;
See also:
SERIAL.
Search the atom direction for a minimum.
Parameters: | ||
Var | The variable name in which the result is stored.. |
Return message:
The number of steps to reach the minimum.
Example:
LINMIN a;
See also:
None.
Find the maximum of two values.
Parameters: | ||
Var1 | First term. If it's a variable name, the result is stored in it. | |
Var2 | Second term. |
Return message:
The maximum value.
Example:
MAX a 11.3;
See also:
MIN.
Find the minimum of two values.
Parameters: | ||
Var1 | First term. If it's a variable name, the result is stored in it. | |
Var2 | Second term. |
Return message:
The minimum value.
Example:
MIN 2.0 11.3;
See also:
MAX.
Set a variable to another one.
Parameters: | ||
Var1 | Destination variable. | |
Var2 | Source variable. |
Return message:
Result of the operation.
Example:
MOV a b;
Arithmetic multiplication between two terms.
Parameters: | ||
Var1 | Multiplicand. If it's a variable name, the result is stored in it. | |
Var2 | Multiplier. |
Return message:
Result of the arithmetic operation.
Example:
MUL a 3.0;
Dump the value of a variable. To know the names of the system variables, click here.
Parameters: | ||
Var | Variable name. If it's undefined, the null value is returned. |
Return message:
The variable value.
Example:
NOP a;
Generate a pseudo-random floating point number in the 0...1 range.
Parameters: | ||
Var | Variable in which the result is stored. |
Return message:
Floating point random number.
Example:
RANDF a;
See also:
None.
SERIAL
(VAR)Var (CHAR)Res
(CHAR)Atom
Set a variable equal to the serial atom number given by the atom name.
Parameters: | ||
Var | Variable name in which the serial number is stored. | |
Res | Residue number. | |
Atom | Atom name. |
Return message:
Serial number.
Example:
SERIAL n 100 ca;
See also:
INDEX.
Define a floating point number variable. All variables are cleared calling the RESET command.
Parameters: | ||
Var | Variable name. | |
Val | Floating point value. |
Return message:
None.
Example:
SETF x 4.25;
Define an integer number variable. All variables are cleared calling the RESET command.
Parameters: | ||
Var | Variable name. | |
Val | Integer value. |
Return message:
None.
Example:
SETI k 1;
Sine trigonometric function.
Parameters: | ||
Var | Angle in radians. |
Return message:
Result of the trigonometric function.
Example:
SIN pi;
Perform the square root.
Parameters: | ||
Var | Square root argument. If it's a variable name, the result is stored in it. |
Return message:
Result of the arithmetic operation.
Example:
SQRT 2.0;
See also:
None.
Arithmetic subtraction between two terms.
Parameters: | ||
Var1 | Minuend. If it's a variable name, the result is stored in it. | |
Var2 | Subtrahend. |
Return message:
Result of the arithmetic operation.
Example:
SUB a 2.42;
Tangent trigonometric function.
Parameters: | ||
Var | Angle in radians. |
Return message:
Result of the trigonometric function.
Example:
TAN 2.23;
Time for calculation speed measurement. In the Unix systems, it gives the number of seconds since the 00:00:00 UTC, January 1, 1970. In the Windows systems, it gives the number of seconds since the power on.
Parameters: | ||
Var | It's the floating point variable name in which the time is stored. |
Return message:
The current time in floating point format.
Example:
TIME tm;
See also:
None.