Derived math functions – Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 205

Advertising
background image

Section 8. Processing and Math Instructions

8-33

The XOR operator also performs a bit-wise comparison of identically
positioned bits in two numeric expressions and sets the corresponding bit in
result according to the following truth table:

If bit in expr1 is

And bit in expr2 is

The result is

0

0

0

0

1

1

1

0

1

1

1

0

XOR Operator Example

The example sets the variable Msg based on the value of variables A, B, and C,
assuming that no variable is a Null. If A = 10, B = 8, and C = 11, the left
expression is True and the right expression is False. Because only one
comparison expression is True, the XOR expression evaluates True.

Dim A, B, C

'Declare variables.

A = 10: B = 8: C = 11

'Assign values.

If A > B XOR B > C Then

'Evaluate expressions.

Msg = True

Else

Msg = False.

End If

Derived Math Functions

The following is a list of nonintrinsic mathematical functions that can be
derived from the intrinsic math functions provided with CRBasic:

Function

CRBasic equivalent

Secant

Sec = 1 / Cos(X)

Cosecant

Cosec = 1 / Sin(X)

Cotangent

Cotan = 1 / Tan(X)

Inverse Secant

Arcsec = Atn(X / Sqr(X * X - 1)) + Sgn(Sgn(X) -1) *

1.5708
Inverse Cosecant

Arccosec = Atn(X/Sqr(X * X - 1)) + (Sgn(X) - 1) * 1.5708

Inverse Cotangent

Arccotan = Atn(X) + 1.5708

Hyperbolic Secant

HSec = 2 / (Exp(X) + Exp(-X))

Hyperbolic Cosecant

HCosec = 2 / (Exp(X) - Exp(-X))

Hyperbolic Cotangent

HCotan = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))

Inverse Hyperbolic Sine

HArcsin = Log(X + Sqr(X * X + 1))

Inverse Hyperbolic Cosine

HArccos = Log(X + Sqr(X * X - 1))

Inverse Hyperbolic Tangent

HArctan = Log((1 + X) / (1 - X)) / 2

Inverse Hyperbolic Secant

HArcsec = Log((Sqr(-X * X + 1) + 1) / X)

Inverse Hyperbolic Cosecant

HArccosec = Log((Sgn(X) * Sqr(X * X + 1) +1) / X)

Inverse Hyperbolic Cotangent HArccotan = Log((X + 1) / (X - 1)) / 2
Logarithm

LogN = Log(X) / Log(N)

Advertising