BIT( ) function

Returns the binary representation for the specified byte position in the current record.

Syntax

BIT(byte_location)

Parameters

byte_location

Numeric. The byte position in the current record to use as the input value.

Output

Character. Returns the binary value as an eight character string.

Remarks

The BIT( ) function converts the byte at the specified byte position into an eight character string of ones and zeros. You can use the BIT( ) function if you need to examine the individual bits in a byte.

If you want to retrieve the character at the specified byte location, use the BYTE( ) function.

Examples

To assign the bit values for bytes 8, 9, and 17 to the variables b8, b9, and b17, specify:

b8 = BIT(8)
b9 = BIT(9)
b17 = BIT(17)

You will find:

Assume that byte position 17 contains a set of 8 credit flags. To extract all customer records that have the third bit set to one (meaning “do not ship”), specify:

SUBSTRING(BIT(17), 3, 1) = "1"

In this example, the SUBSTRING( ) function is used to extract the value of the third bit.

Related reference
BYTE( ) function
SUBSTR( ) function


(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback