BIT( ) function

Returns the binary representation for the specified byte position in the current record as an eight character string.

Syntax

BIT(byte_location)

Parameters

Name Type Description
byte_location numeric The byte position to return as a binary value.

Output

Character.

Examples

Basic examples

Returns "00110001" if the eighth byte contains "1":

BIT(8)

Returns "01000001" if the ninth byte contains "A":

BIT(9)

Returns "01100001" if the seventeenth byte contains "a":

BIT(17)

Advanced examples

Using BIT ( ) and SUBSTRING ( ) to extract a value

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:

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

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

Remarks

How it works

BIT( ) converts the byte at the specified byte position into an eight character string of ones and zeros.

When to use BIT( )

Use BIT( ) to examine the individual bits in a byte.

Related functions

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

ACL Scripting Guide 14.1