beautypg.com

And operator – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 290

background image

Section 8. Processing and Math Instructions

ACOS Function Example
The example uses ACOS to calculate

π

. By definition, a full circle is 2

π

radians. ACOS(0) is

π

/2 radians (90 degrees).

Public Pi

'Declare variables.

Pi = 2 *

ACOS

( 0 )

'Calculate Pi.

AND Operator

Used to perform a bit-wise conjunction on two numbers.

Syntax
result = number1

AND

number2

The AND operator performs a bit-wise comparison of identically positioned bits in
two numbers and sets the corresponding bit in result according to the following truth
table:
If bit in

AND bit in

The result

number1 is

number2 is

is

0 0 0

0 1 0

1 0 0

1 1 1

Although

AND

is a bit wise operator, it is often used to test Boolean

(True/False) conditions. The CR9000X decides if something is true or false on
the criteria that 0 is false and any non-zero number is true (Section 4.5).
Because AND is a bit wise operation it is possible to

AND

two non-zero

numbers (e.g., 2 and 4) and get 0. The binary representation of –1 has all bits
equal 1. Thus any number AND –1 returns the original number. That is why
the pre defined constant, True = -1.

The predefined constant True = -1
The predefined constant False = 0

If number1 is:

AND number2 is:

The result is:

-1 Any

number

number2

-1

NAN (not a number)

NAN

0 Any

number 0

0 NAN

NAN


Expressions are evaluated to a number (Section 4.5) and can be used in place of
one or both of the numbers. Comparison expressions evaluate as True (-1) or
False (0) For example:

If Temp(1) > 50

AND

Temp(3) < 20 Then

X = True
Else
X = False
EndIf

and

X = Temp(1) > 50

AND

Temp(3) < 20

8-4