| Mathematical Operations |
|
:= not = to assign a value to a variable.int := 3;
Addition ...................... x := y + z;
Subtraction ................... x := y - z;
Multiplication ................ x := y * z;
Division ...................... x := y / z;
Integer division .............. x := y div z;
Modulo arithmetic ............. x := y mod z;Integer Division: One integer is divided by another and the integer part of the result is returned.
Modulo Arithmetic (Remainder Arithmetic): x := y mod z;
The above finds the remainder of y/z and puts it into x.
These mathematical operations are pretty self explanatory.
Syntax:
SQR(Real Variable)
Explanation:
SQR returns the square of the real variable that is passed to it, pretty simple really.
Example:
x := SQR(y);
This finds the square of y and puts the result in x.
Syntax:
SQRT(Real Variable)
Example:
x := SQRT(y);
This finds the square root of y and puts the result in x.
Syntax:
SIN(Real variable)
Explantation:
SIN returns the sin of the number that is passed to it. Unfortunately this is in radians(stupid radians).
2*pi radians is equal to 360 degrees, so to convert from degrees to radians it is degrees/180 * pi,
and from radians to degrees it is radians/pi * 180. It is a bit of a hassle but nevermind.
Example:
x := SIN(y);
This finds the sin of y(radians) and puts the value in x.
Syntax:
COS(Real variable)
Explantation:
COS returns the cos of the number that is passed to it. This is also in radians. If you want to
know how to convert
radians into degrees and vice-versa then read the explanation of SIN.
Example:
x := COS(y);
This finds the cos of y(radians) and puts the value in x.
Syntax:
ARCTAN(Real variable)
Explantation:
ARCTAN returns the inverse tanget of the number that is passed to it.
It returns the angle in radians (gasp).
Example:
x := ARCTAN(y);
This finds the inverse tangent, in radians, of y and puts the value in x.
To find tanget just divide sin(Y) by cos(Y).
e.g x := sin(y)/cos(y); finds the tangent of y and puts it in x (remember radians).
To find INVERSE SIN or INVERSE COS do the following...
INVERSE SIN = ARCTAN(y/sqrt(1-sqr(y)))
INVERSE COS = ARCTAN(sqrt(1-sqr(x))/x)
So x := arctan(y/sqrt(1-sqr(y))); finds the inverse sin of y and puts it in x.
So x := arctan(sqrt(1-sqr(x))/x); finds the inverse cos of y and puts it in x.