Skip to Content.
Sympa Menu

freetds - Re: TDS 7.0 (cvs), float types, MS SQL 7

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Bob Kline <bkline AT rksystems.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: TDS 7.0 (cvs), float types, MS SQL 7
  • Date: Sat, 26 Feb 2000 09:47:30 -0500 (EST)


On Sat, 26 Feb 2000, Michael Suedkamp wrote:

> Brian,
>
> I should have tested a little more before posting. I cannot obtain values
> like "1", "1.5", "2", "2.5". For some reason these kind of values I expect
> in our database.
> However, I can obtain values like "1.4","1.6", "2.2" etc. ???????
>
> The field in MS SQL 7 is of the "real" type (4 byte).
>
> I added this code to the value_as_string function in tdstest.c:
>
> ...
> TDS_REAL theReal;
> ...
> switch(type) {
> ...
> case 109: // This value is reported for the column type
> // for both real types.
> // I know I have to handle the 8 byte type differently ...
> memcpy(&theReal, value, 4);
> sprintf(result, "%.6f", theReal);
> break;
> ...
> }
>

Perhapd the fact that it's stored as 4 bytes in your database doesn't
necessarily imply that your code is getting it as 4-byte values. What
happens if you do this?

double surReal;
memcpy(&surReal, value, sizeof surReal);
sprintf(result, "%.6f", surReal);

--
Bob Kline
mailto:bkline AT rksystems.com
http://www.rksystems.com





Archive powered by MHonArc 2.6.24.

Top of Page