informix
INFORMIX-ESQL/C Programmer's Manual
ESQL/C Function Library

dececvt() and decfcvt()

The dececvt() and decfcvt() functions are analogous to the subroutines under ECVT(3) in section three of the UNIX Programmer's Manual. The dececvt() function works in the same fashion as the ecvt(3) function, and the decfcvt() function works in the same fashion as the fcvt(3) function. They both convert a decimal type number to a C char type value.

Syntax

Usage

The dececvt() function converts the decimal value to which np points into a
null-terminated string of ndigit ASCII digits and returns a pointer to the string. A subsequent call to this function overwrites the string.

The dececvt() function rounds low-order digits.

The decfcvt() function is identical to dececvt(), except that ndigit specifies the number of digits to the right of the decimal point instead of the total number of digits.

Let dec_val point to a decimal value of 12345.67 and suppress all arguments except ndigit. The following table shows the values that the dececvt() function returns for four different ndigit values.

ndigit Value Return String *decpt Value *sign
4 "1235" 5 0
10 "1234567000" 5 0
1 "1" 5 0
3 "123" 5 0

For more examples of dec_val and ndigit values, see the sample output of the dececvt.ec demo program on page B-40.

Warning: When you write thread-safe ESQL/C applications, do not use the dececvt() or decfcvt() library functions. Instead, use their thread-safe equivalents, ifx_dececvt() and ifx_decfcvt(). For more information, see Chapter 13, Using Informix Libraries.

Example: dececvt()

The file dececvt.ec in the demo directory contains the following sample program.

dececvt() Output

Example: decfcvt()

The file decfcvt.ec in the demo directory contains the following sample program.

decfcvt() Output


INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved