Subject RE: [ib-support] Firebird Workbench, number formats, retrieving data with API
Author Ann W. Harrison
At 11:54 PM 1/25/2003 +0100, Henrik Sitter wrote:

>Thanks for your reply. I'm trying to decode the binary representation of
>a float (using firebird v.1.0.0). Do you know if "IEEE 754 floating
>point", "D_FLOAT floating point" or "G_FLOAT floating point" is used?

Ah! That's easy. IEEE. Except on VAXes.

>What about big endian or little endian?

Depends on your client architecture. Firebird returns values
in the appropriate format for the client. The data is sent
over the wire in XDR (basically the native Sun format of
1985) and translated at either end to the native format of
the server (at one end) or client (at the other).



>So far I have not been able to decode correctly (trying all three (or
>six) encodings), but I have done some testing and I'm pretty sure that
>my database returns the correct binary representation. Here are some
>examples:
>
>If I store 201 (as float/double precision), it returns:
>Byte 7: 64
>Byte 6: 105
>Byte 5: 32
>Byte 4 to byte 0: 0
>
>If I store 202 (as float/double precision), it returns:
>Byte 7: 64
>Byte 6: 105
>Byte 5: 64 (+32 compared to storing 201)
>Byte 4 to byte 0: 0
>
>If I store 203 (as float/double precision), it returns:
>Byte 7: 64
>Byte 6: 105
>Byte 5: 96 (+32 compared to storing 202)
>Byte 4 to byte 0: 0


Errr... If I remember correctly, the sign, mantissa, and
exponent of a floating point number don't align neatly
on byte boundaries, which may explain this confusion. Being
a slothful person, I haven't looked hard at your code, but
if you're writing in C, have you tried a printf of the
value returned? Or declaring an appropriate variable,
assigning values to it and comparing those, bytewise, with
what you're seeing?


Regards,

Ann
www.ibphoenix.com
We have answers.