Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual
Page 83

Operating Functions
Chapter 5
5–46
5.5.2.1.6 RND
Returns a pseudo-random number in the range between 0 and 1 inclusive.
The RND operator uses a 16-bit binary seed and generates 65536
pseudo-random numbers before repeating the sequence. The numbers
generated are specifically between 0/65535 and 65535/65535 inclusive.
Unlike most BASICS, the RND operator in the BASIC Module does not
require an argument or a dummy argument. If an argument is placed after
the RND operator, a BAD SYNTAX error occurs.
Examples:
uPRINT Rnd
.30278477
5.5.2.1.7 PI
PI is a stored constant. In the BASIC Module PI is stored as 3.1415926.
5.5.2.2
Log Functions
Following are the log functions.
5.5.2.2.1 LOG([expr])
Returns the natural logarithm of the argument. The argument must be
greater than 0. This calculation is carried out to 7 significant digits.
Examples:
uPRINT LOG(12)
uPRINT LOG(EXP(1))
2.484906
1
5.5.2.2.2 EXP([expr])
This function raises the number “e” (2.7182818) to the power of the
argument.
Examples:
uPRINT EXP(1)
uPRINT EXP(LOG(2))
2.7182818
2
5.5.2.3
Trig Functions
5.5.2.3.1 SIN([expr]
Returns the sine of the argument. The argument is expressed in radians.
Calculations are carried out to 7 significant digits. The argument must be
between
"200000.
Examples:
uPRINT SIN(PI/4)
uPRINT SIN(0)
.7071067
0
5.5.2
Unary Operators
(continued)