![Campbell CR9000 Instruction Manual Download Page 171](http://html1.mh-extra.com/html/campbell/cr9000/cr9000_instruction-manual_489197171.webp)
Section 8. Processing and Math Instructions
8-11
Int, Fix Functions
Return the integer portion of a number.
Syntax
Int(
number
)
Fix(
number
)
Remarks
The argument
number
can be any valid numeric expression. Both
Int
and
Fix
remove the fractional part of
number
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.
Fix(number)
is equivalent to:
Int and Fix Function Example
This example illustrates the use of Int and Fix.
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 Function
Returns the natural logarithm of a number.
Syntax
Log(
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-10 logarithms:
Log10 =
Log
(X) /
Log
(10)
Log Function Example
The example calculates the value of e, then uses the Log function to calculate the
natural logarithm of e to the first, second, and third powers.
Summary of Contents for CR9000
Page 6: ...CR9000 Table of Contents iv This is a blank page ...
Page 22: ...CR9000 Overview OV 16 This is a blank page ...
Page 26: ...Section 1 Installation 1 4 CR9000 FIGURE 1 1 3 CR9000 Battery Pack ...
Page 72: ...Section 3 CR9000 Measurement Details 3 28 This is a blank page ...
Page 88: ...Section 5 Program Declarations 5 6 This is a blank page ...
Page 217: ...This is a blank page ...