DIGITS

The DIGITS function returns a fixed-length character string representation of a numeric value.

Syntax

DIGITS( val )

val

The value that you want converted into a string representation. This can be a numeric, CHAR, or VARCHAR value.

Results

This function converts the input val into a fixed-length string.

The length of the output string is determined by the data type of the val argument, as show in the following table:

Input Value Type Length of Result String
TINYINT,
SMALLINT
5
INT 10
BIGINT 19
DECIMAL The precision of the DECIMAL value.
FLOAT with precision <= 23,
REAL
23
FLOAT with precision > 23,
DOUBLE
52
CHAR,
VARCHAR
31
( The value is converted to DECIMAL(31,6) )

The return value is left-padded with 0’s if the number of digits is less than the fixed-length of the result string.

Examples

splice> VALUES( DIGITS( 12345 ) );
1
--------------
0000012345

splice> VALUES( DIGITS( 123.45 ) );
1
--------------
12345


splice> VALUES( DIGITS( '12345' ) );
1
------------------------
0000000000000000000012345000000

splice> VALUES( DIGITS( '123.45' ) );
1
------------------------
0000000000000000000000123450000