| PL/i Programming Language for i.CanDoIt |
| This set of pages will provide brief tutorials about programming in PL/i. This language is more simple than C, but more structured than Basic. The objective in creating this language was to compile compact code that would run efficiently and safely as a virtual machine, like a very lean Java. |
 |
| Index of PL/i Tutorials |
|
|
|
Tutorial #3
Assignment Statements and Math: Plain Old "a=b+c"
|
Math Functions & Operators
The following is a summary of math operators recognized in PL/i. These operate on either int or float data types.
|
+
|
Addition
|
|
-
|
Subtraction
|
|
*
|
Multiplication
|
|
/
|
Division |
|
%
|
Modulus |
|
abs(n)
|
Returns absolute value of 'n' |
The following is a summary of math functions recognized in PL/i. These operate on int or float data types, but always return a float data type (except rand). The trigonometry functions operate on units of radians (not degrees - see conversion example below).
|
acos(n)
|
Calculates arc cosine of 'n' |
|
asin(n)
|
Calculates arc sine of 'n' |
|
atan(n)
|
Calculates arc tangent of 'n' |
|
cos(n)
|
Calculates cosine of 'n' |
|
ln(n)
|
Produces the natural logarithm of n |
|
log(n)
|
Products the logarithm of n |
|
pow(x,y)
|
Produces x raised to the power of y |
|
sin(n)
|
Calculates sine of 'n' |
|
sqrt(n)
|
Calculates square root of 'n' |
|
tan(n)
|
Calculates tangent of 'n' |
|
|
|
|
rand()
|
Provides a random integer in the range of 0 to 2,147,483,647 on the server, or 0..32,767 on the I/O coprocessor
(use srand(n) to seed random number generator) |
Logic Operators for data
The following is a summary of logic operators recognized in PL/i for use on integer data types (operate on int, return int).
|
&
|
Logical AND, bitwise, e.g., c = a & b;
|
|
~
|
Logical NOT, bitwise (invert each bit), e.g., a = ~b;
|
|
|
|
Logical OR, bitwise , e.g., c = a | b;
|
|
^
|
Logical Exclusive OR, bitwise , e.g., c = a ^ b; |
|
<<
|
Logical Shift Left, bitwise,
e.g., a = a << 3; will shift the contents of "a" left 3 bits |
|
>>
|
Logical Shift Right, bitwise,
e.g., a = a >> 5; will shift the contents of "a" right 5 bits |
|
|
|
|