Convert float to decimal in Informix

Posted by prabhu on Stack Overflow See other posts from Stack Overflow or by prabhu
Published on 2010-04-20T06:47:49Z Indexed on 2010/04/20 11:43 UTC
Read the original article Hit count: 375

Filed under:
|
|
|

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

Since we use memcpy to copy data to and from ESQL/C structure to C structure, there is an issue with decimal to float conversion. When I searched the Informix ESQL/C Programmer's manual, I couldn't find any function that can do this. Google search led me to the deccvflt() function. This function converts from a float to a decimal type.

Though I couldn't find this function listed in the manual, I see the declarations in decimal.h. Are these functions still recommended to be used?

Alternatively, I was also thinking about using the decimal type in the C structure also, as it happens to be a C structure. This way, I can still use the memcpy right?

Please share your thoughts.

IBM Informix Dynamic Server Version 11.50.FC3

Thanks, prabhu

© Stack Overflow or respective owner

Related posts about informix

Related posts about esql