beautypg.com

Int(source), fix(source), Log(source) or ln(source) – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 309

background image

Section 8. Processing and Math Instructions

If bit in expression1 is

And bit in expression2 is

The result is

0 0

1

0 1

1

1 0

0

1 1

1

INT(Source), Fix(Source)

The INT function returns the integer portion of a number.

Syntax

Int(source)

Fix(

source

)

Remarks
The argument source can be any valid numeric expression. Both INT and FIX
remove the fractional part of source and return the resulting integer value.

If the numeric expression results in a Null, INT and FIX return a Null.

The difference between INT and FIX is that if number is negative, INT returns the
first negative integer less than or equal to number, whereas FIX returns the first
negative integer greater than or equal to number. For example, INT converts -8.4 to
-9, and FIX converts -8.4 to -8.

Int and Fix Function Example

Dim A, B, C, D

'Declare variables.

BeginProg
A

=

INT

(-99.8)

'Returns -100

B

=

FIX

(-99.8)

'Returns -99

C

=

INT

(99.8)

'Returns 99

D

=

FIX

(99.8)

'Returns 99

EndProg

LOG(Source) or LN(Source)

Returns the natural logarithm of a number. LOG and LN perform the same function.

Syntax

LOG(

number

) or LN(

number

)

Remarks
The argument number can be any valid numeric expression that results in a value
greater than 0. The natural logarithm is the logarithm to the base e. The constant e
is approximately 2.718282.
You can calculate base-n logarithms for any number x by dividing the natural
logarithm of x by the natural logarithm of n as follows:
Logn(x) = LOG(x) / LOG(n)
The following example illustrates a procedure that calculates base-4 logarithms:
Log4 = LOG(X) / LOG(4)

8-23