TDS 7.0 (cvs), float types, MS SQL 7
Bob Kline
bkline at rksystems.com
Sat Feb 26 09:47:30 EST 2000
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
More information about the FreeTDS
mailing list