IBM FileNet P8, Version 5.2.1            

Numeric functions

This section contains brief descriptions of the functions that apply to float or integer values.

Table 1. Table of functions that apply to float or integer values
Function What it does
abs Returns the absolute value of the numeric function.
bitor, bitand, bitnot Provides Boolean manipulation of bits.
convert Converts a number to another data type or converts another data type to a number.
err_encode Converts a three-part FileNet® P8 error tuple into a single-part integer.
int Truncates everything after the decimal point and returns the integer value of a numeric expression.
max Returns the largest value from a list of expressions of any supported data type.
min Returns the smallest value from a list of expressions of any supported data type.
mod Returns the remainder after division (modulus).
numbertostring Converts a numeric expression to a string expression, using a specified mask.
random Returns a random integer within a specified range.
sizeof Returns the size of an array.

abs

This function returns the absolute value of an integer or float expression. Use the following syntax:
abs (num_expr)
where num_exp is an expression whose result is of type integer or float. For example:
abs (SalePrice - PurchasePrice)

bitand, bitor, and bitnot

These functions provide Boolean manipulation of bits; use them to perform many tasks, such as masking setting, and extracting bits. Each of these functions can perform Boolean operations on up to 32 items at the same time.

If you are familiar with the 'C' programming language, then bitand, bitor, and bitnot are like logical and (&), logical or (|), and logical not (~), respectively. If you are not familiar with 'C', then consider the numbers to be binary values (for example, 123 would be 1111011).

These functions take integers of 32 bits (that is, from 0 through 42946967295) as input and return integers in the same range as output. Use the following syntax:
bitand (expr1, expr2)

bitor (expr1, expr2)

bitnot (expr)
where expr1 and expr2 are integers of 32 bits.
For specific information about and examples of each function, select a topic from the list below.

bitand

The bitand function "ands" the corresponding bits in two integers. This is a bit-by-bit comparison, the result of which is output to a new integer. The comparison follows these rules:
  • If both integers contain a 1 in the same position, the resulting integer also contains a 1 in that position.
  • If both integers contain a 0 in the same position, the resulting integer also contains a 0 in that position.
  • If one integer contains a 1 and the other integer contains a 0 in the same postion, the resulting integer contains a 0 in that position.
For example, bitand (123, 240) can be visualized as follows.
bitand

     (00000000000000000000000001111011,
         

      00000000000000000000000011110000)
          

  results in: 
      00000000000000000000000001110000

bitor

The bitor function "ors" the corresponding bits in two integers. The result of this bit-by-bit comparison is output to a new integer. The comparison follows these rules:
  • If either integer contains a 1 in the same position, the resulting integer also contains a 1 in that position.
  • If both integers contain a 0 in the same position, the resulting integer also contains a 0 in that position.
For example, bitor (123, 240) can be visualized as follows.
bitor
     (00000000000000000000000001111011,
         
      00000000000000000000000011110000)
          
  results in:

      00000000000000000000000011111011

bitnot

The bitnot function "nots" an integer; the result of this bit-by-bit analysis is output to a new integer. For each position, the new integer contains the opposite bit value-meaning, for example, that if the input integer contains a 1 in a given position, the new integer contains a 0 in the same position.

For example, bitnot (123) can be visualized as follows.
bitnot
              (00000000000000000000000001111011
  results in:
               11111111111111111111111110000100

int

This function computes the integer value of a float expression by truncating everything after the decimal point. For example, the float values 6.2 and 6.8 are converted to the integer value 6. The sign of the number does not change.

Use the following syntax:
int (num_expr)
where num_expr is an expression whose result is of type float. For example:
int (365 / 7)

mod

This function returns the remainder after division (modulus). Note that if you try to divide a value by zero, a runtime error occurs.

Use the following syntax:
mod (num1, num2)
where num1 and num2 are variables of type float or integer, and can contain negative values.
In the following example, the function returns the remainder of the division of NumberOfDays by 7.
mod (NumberOfDays, 7)
Note that the sign of num2 determines the sign of the mod function's output (when the output is not equal to 0):
If num2 > 0,

		0 <= mod (num1, num2) < num2

If num2 < 0,

		num2 < mod (num1, num2) <= 0

random

Some applications need a way to generate a random integer, perhaps as a means of performing random sampling. This function returns a random integer within a specified range. It requires an integer as a parameter to determine the range.

Use the following syntax:
random (num)
where num is an integer from 2 through 32768 (inclusive of both ends). The range is between 0 and num - 1. In the above example, if num were 23, the random integer would fall between 0 and 22.

err_encode

This function converts a three-part FileNet P8 error tuple into a integer value, which you can compare to a result code returned by a call to a WorkFlo Application Libraries (WAL) entry point. WAL returns result codes when exception conditions in normal processing occur (such as end-of-file in simple data processing), or when errors occur.

The primary use for err_encode is to base subsequent processing of a work item on the results returned by an operation that calls WAL. Typically, such an operation is followed by a Branch system Instruction; when the Branch executes, the work item follows the processing path determined by the result code that the previous operation returned. For example, use the err_code function in the Branch definition to indicate that if <return code> = err_encode (80, 0, 2), the work item follows one processing path, while it follows another processing path if <return code> = err_encode (80, 0, 5).

Use the following syntax:
err_encode (mod_num, func_num, err_num)
where:
Table 2. Parameters and description for err_encode function
Parameter Description
mod_num The first part of the result code. It is an integer expression (ranging from 0-255) that indicates which service, library, or application is the source of the error.
func_num The second part of the result code. It is an integer expression (ranging from 0-255) that indicates which function or module the error comes from, or the category to which the error belongs.
err_num The third part of the result code. It is an integer expression (ranging from 0-65535) that indicates the error number.


Last updated: March 2016
bpfe010.htm

© Copyright IBM Corporation 2016.