BIT Function

Purpose

Converts an arithmetic or string value to a bit string.

Syntax

BIT(s)

or

BIT(s,l)

Parameters

s is an arithmetic or string value of an optionally specified length l, and l is a positive integer.

Description

The BIT function converts an arithmetic or string value to a bit string of an optionally specified length.

s is first converted to a bit string whose length is determined by the rules for data type conversion given in the chapter Data Type Conversions. Then, if the length l is specified, the bit string is truncated on the right or padded on the right with zero bits to the specified length.

Examples

DECLARE INTEGER FIXED BINARY(15); 
DECLARE BIT_STRING BIT(15);

INTEGER = 20;
BIT_STRING = BIT(INTEGER);
/* BIT_STRING NOW EQUALS '000000000010100'B */

Restrictions

None.