![]() |
|
The database server supports the following data types for floating-point values.
When you use the C float data type (for SMALLFLOAT values), be aware that most C compilers pass float to a function as the double data type. If you declare the function argument as a float, you might receive an incorrect result. For example, in the following excerpt, :hostvar might produce an incorrect value in tab1, depending on how your C compiler handles the float data type when your program passes it as an argument.
For more information on the SQL floating point data types, see the Informix Guide to SQL: Reference
When an ESQL/C program fetches a floating-point column value into a character host variable (char, fixchar, varchar, or string), it includes only the number of decimal digits that can fit into the character buffer. If the host variable is too small for the full precision of the floating-point number, ESQL/C rounds the number to the precision that the host variable can hold.
In the following code fragment, an ESQL/C program retrieves the value 1234.8763512 from a FLOAT column that is called principal into the prncpl_strng character host variable:
Because the prncpl_strng host variable is a buffer of 15 characters, ESQL/C is able to put all decimal digits into the host variable and this code fragment produces the following output:
However, if the preceding code fragment declares the prncpl_strng host variable as a buffer of 10 characters, ESQL/C rounds the FLOAT value to fit into prncpl_strng and the code fragment produces the following output:
ESQL/C assumes a precision of 17 decimal digits for FLOAT or SMALLFLOAT values. For DECIMAL(n,m), ESQL/C assumes m decimal digits.