Logarithmic operators, Logarithmic operators -11, Log([expr]) – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 33: Exp([expr])

Advertising
background image

Publication 1746-RM001A-US-P

Expressions and Operators 3-11

RND

Use the RND operator to return 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.

Logarithmic Operators

The module contains a complete set of logarithmic operators. These operators are
single-operand operators.

LOG([expr])

Use the LOG operator to return the natural logarithm of the argument. The
argument must be greater than 0. This calculation is carried out to 7 significant
digits.

If base 10 logs are needed, the following expression may be used:

log

10

(x)=log(x)/log(10)

The log is natural.

EXP([expr])

Use the EXP operator to raise the number e (2.7182818) to the power of the
argument.

IMPORTANT

Unlike most BASIC languages, the RND operator in the module
does not require an argument or a dummy argument. If an
argument is placed after the RND operator, a bad syntax error
occurs.

Example

Result

>PRINT RND

.26771954

Example

Result

>PRINT LOG(12)

2.484906

>PRINT LOG(EXP(1))

1

Example

Result

>PRINT EXP(1)

2.7182818

>PRINT EXP(LOG(2))

2

Advertising