BITVAL: Evaluating a Bit String as an Integer

How to:

The BITVAL function evaluates a string of bits within a character string. The bit string can be any group of bits within the character string and can cross byte and word boundaries. The function evaluates the subset of bits in the string as an integer value.

If the number of bits is:


Top of page

x
Syntax: How to Evaluate a Bit String
BITVAL(source_string, startbit, number, output)

where:

source_string

Alphanumeric

Is the character string to be evaluated.

startbit

Integer

Is the number of the first bit in the bit string, counting from the left-most bit in the character string. If this argument is less than or equal to 0, the function returns a value of zero.

number

Integer

Is the number of bits in the subset of bits. If this argument is less than or equal to 0, the function returns a value of zero.

output

Integer



Example: Evaluating a Bit String

BITVAL evaluates the bits 12 through 20 of LAST_NAME and stores the result in a column with the format I5:

BITVAL(LAST_NAME, 12, 9, 'I5')

For SMITH, the result is 332.

For JONES, the result is 365.


iWay Software