![]() |
|
ESQL/C supports the SQL DECIMAL and MONEY data types with the decimal data type. The decimal data type is a machine-independent method that represents numbers of up to 32 significant digits, with valid values in the range 10-129 to 10+125.
The DECIMAL data type can take the following two forms:
For a complete description of the DECIMAL data type, see the Informix Guide to SQL: Reference.
Use the decimal data type to declare host variables for database values of type DECIMAL. A structure of type decimal represents a value in a decimal host variable, as follows:
The decimal.h header file contains the decimal structure and the typedef dec_t. Include this file in all C source files that use any decimal host variables with the following include directive:
The decimal structure stores the number in pairs of digits. Each pair is a number in the range 00 to 99. (Therefore, you can think of a pair as a base-100 digit.) Figure 5-2 shows the four parts of the decimal structure.
Figure 5-2
Figure 5-3 shows some sample decimal values.
Figure 5-3
You can use the deccvasc demonstration program to experiment with how ESQL/C stores decimal numbers.
You must perform all operations on decimal type numbers through the following ESQL/C library functions for the decimal data type. Any other operations, modifications, or analyses can produce unpredictable results. For more information on the syntax and behavior of these functions, refer to the referenced pages.
For information about the function rfmtdec(), which allows you to format a decimal number, see Numeric-Formatting Functions. For additional information on decimal values, see Using Operations That Involve a Decimal Value