Re: db-lib DBNUMERIC structure
LacaK <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote / napísal(a): > On Mon, Sep 12, 2011 at 01:11:01PM +0200, LacaK wrote: > >> typedef struct dbnumeric >> { >> char precision; >> char scale; >> unsigned char val[MAXNUMLEN]; >> } DBNUMERIC; >> >> for retrieving exact numeric data. >> >> But I can not find, how to interpret/read "val" array to construct number. >> > > Just to remind you, you could just bind the type to DBFLT4 or DBFLT8 > (FLT4BIND or FLT8BIND). Or use dbconvert(). Yes, thank you. dbconvert() works as expected, I can also convert to SQLCHAR (to not lose precision) ;-) > > > If you want the sausage-factory details, cf. tds_convert() source code. > Yes, I found tds_numeric_to_string() in numeric.c where I can see how it works. I only wonder why sybase uses variable length array (see tds_numeric_bytes_per_prec) with high significant bytes first (so I must start with high array index and walk down). Microsoft approach seems to me simpler (with low significant bytes first, so I start with index 0 and walk to end of array) Thanks -Laco. > --jkl > _______________________________________________ > FreeTDS mailing list > [email protected] > http://lists.ibiblio.org/mailman/listinfo/freetds > >