DECIMAL functions for C

The following DECIMAL functionality is available only to users of IBM® Informix® ESQL/C. To use these functions, ESQL/C users must manually link their C code to the ESQL/C libraries.

The data type DECIMAL is a machine-independent method for representing numbers of up to 32 significant digits, with or without a decimal point, and with exponents in the range -128 to +126. ESQL/C provides routines that facilitate the conversion of DECIMAL-type numbers to and from every data type allowed in the C language. DECIMAL-type numbers consist of an exponent and a mantissa (or fractional part) in base 100. In normalized form, the first digit of the mantissa must be greater than zero.

The DECIMAL date type is internally represented with the dec_t structure. The decimal structure and the type definition dec_t can be found in the header file decimal.h, which is included in the ESQL/C product. Include this file in all C source files that use any of the decimal functions.

All operations on decimal type numbers must be performed using the following ESQL/C library functions for the decimal data type. Any other operations, modifications or analyses can produce unpredictable results.

Function Name Description
deccvasc( ) Converts C int1 type to DECIMAL type
dectoasc( ) Converts DECIMAL type to C int1 type
deccvint( ) Converts C int type to DECIMAL type
dectoint( ) Converts DECIMAL type to C int type
deccvlong( ) Converts C int4 type to DECIMAL type
dectolong( ) Converts DECIMAL type to C int4 type
deccvflt( ) Converts C float type to DECIMAL type
dectoflt( ) Converts DECIMAL type to C float type
deccvdbl( ) Converts C double type to DECMAL type
dectodbl( ) Converts DECIMAL type to C double type
decadd( ) Adds two DECIMAL numbers
decsub( ) Subtracts two DECIMAL numbers
decmul( ) Multiplies two DECIMAL numbers
decdiv( ) Divides two DECIMAL numbers
deccmp( ) Compares two DECIMAL numbers
deccopy( ) Copies a DECIMAL number
dececvt( ) Converts DECIMAL value to ASCII string
decfcvt( ) Converts DECIMAL value to ASCII string

For more information about the individual functions, see the following: IBM Informix ESQL/C Programmer's Manual.


Feedback