Convert float to decimal in Informix

I have a table with a decimal column. There is an ESQL / C framework that represents a table. It is of type decimal. I also have a normal C structure for an equivalent for the same table. The type of the above field is float.

Since we are using memcpy to copy data from ESQL / C structure to C structure, there is a problem with decimal to float conversion. When I searched for the Informix ESQL / C Programmer's Guide, I couldn't find any functions that could do this. A google search led me to the deccvflt () function. This function converts from float to decimal.

Although I couldn't find this function mentioned in the manual, I see declarations in decimal.h. Are these features still recommended?

Alternatively, I was also thinking about using a decimal type in the C structure, since it appears to be a C structure. So I can still use memcpy correctly?

Share your thoughts.

IBM Informix Dynamic Server Version 11.50.FC3

Thank you prabh

+2


a source to share


1 answer


You can convert to float or decimal directly in your query using the listing

select name_of_float::decimal(8,2) from table

      



or

select name_of_decimal::float from table

      

+1


a source







All Articles