Sgn (source), Sin (source) – Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 201

Advertising
background image

Section 8. Processing and Math Instructions

8-29

Here, upperbound is the highest number in the range, and lowerbound is the
lowest number in the range.

Rnd Function Example
The example uses the Rnd function to generate random integer values from 1
to 9. Each time this program is run, Randomize generates a new random-
number sequence.

Dim Wild1, Wild2

'Declare variables.

Randomize

'Seed random number generator.

Wild1 = Int(9 * Rnd + 1)

'Generate first random value.

Wild2 = Int(9 * Rnd + 1)

'Generate second random value.

Sgn (Source)

Used to find the sign value of a number.

Syntax
x = Sgn (
source)

Remarks
Returns an integer indicating the sign of a number.

The argument number can be any valid numeric expression. Its sign
determines the value returned by the Sgn function:

If X > 0, then Sgn(X) = 1.

If X = 0, then Sgn(X) = 0.

If X < 0, then Sgn(X) = -1.

Sgn Function Example

The example uses Sgn to determine the sign of a number.

Dim Msg, Number

'Declare variables.

Number = Volt(1)

'Get user input.

Select Case Sgn(Number)

'Evaluate Number.

Case 0

'Zero.

Msg = 0

Case 1

'Positive.

Msg = 1

Case -1

'Negative.

Msg = -1

End Select

Sin (Source)

Returns the sine of an angle.

Syntax
x = Sin
(source)

Remarks
Source can be any valid numeric expression measured in radians.

Advertising