Re: ESQL/C Floats returned as CHAR
Posted in 1994
>From: rrl@ccd.harris.com (Ron (Jose) Larson) >Subject: ESQL/C Floats returned as CHAR >Date: Wed, 16 Feb 1994 16:18:44 GMT >X-Informix-List-Id: <news.5572> > >I remember some talk on this a while back ... sorry but can't find >answer anymore. We have an application that uses ESQL/C to read tables and >then forces the sqlda to return char. Problem we are having is that the >floating point values are being returned using the default of 2 decimal >places. I know that using piped, isql, there is the undocumented DBFLTMASK >environment variable which is used to set the precision. But what is the >counterpart on ESQL/C? > >I remember a long answer on this about a month ago ... can't find it anymore! I don't know what was said a month or so ago, but... If you want the precision of your floats preserved and have a strong reason for not retrieving them into a double in the sqlda structure, then the best alternative is to use a decimal instead. I wouldn't trust the conversion to character string unless I wrote it using the ESQL/C format routines. Speaking from lots of empirical evidence, of which yours is just another sample, the internal conversion routines have an erroneous fixation that every number which isn't an integer has 2 decimal places. I know that's wrong, so I code to make sure that the software doesn't get a chance to screw it up. Yours Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>