Subject Re: [firebird-support] Floating point value issue
Author Mitchell Peek
Floats in FB are likely different then you suspect. (see Helen's Book
pg 139) ;)

Floating points are different then fixed decimal types decimal and
numeric. To quote Helen, they have a "sliding window of precision".
This allows floats to handle numbers over a much broader range of
numbers but to the detriment of exactness.

3.65478 is maintained at a value very close to its exact value, however
the large numbers you wrote lose exactness due to the lack of precision
over that magnitude.

Therefore, they make very poor candidates for Prim, Foreign, or unique
keys. Likewise, equality operators can't be depended to work on them as
you might expect but are better determined using "between" some
acceptable fault tolerance.

As an example,
where myFloat between 23.0001 and 23.0000

You should consider adding a pseudo primary key for this table populated
with a generator, or choose some other "alternate" key if it exists.




Craig wrote:

>Hello all,
>
>I inherited an SQL table which uses a floating point value as the
>ID, and i converted this table into a Firebird Table, maintaining
>the floating point type for the ID, however I have noticed the
>floating point values are not the same when i view these values, for
>example -
>
>SQL Float ID = 110479018921127.0
>FDB Float ID = 110479015936000.0
>
>Via ISQL when i perform the - Select * from TABLE WHERE ID =
>######################## - both numbers return the exact same
>record as indicated by a date/time field
>
>Are there issues with Floats in Firebird { using version 1.5.2 as an
>Embedded Server in this instance, but also a Classic Server }
>
>Any help or understanding would be appreciated.
>
>thanks
>craig
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>