Subject Re: Bug: "-0" <> "0" in FB indexes !!!
Author bjorgeitteno
--- In firebird-support@yahoogroups.com, Daniel Rail <daniel@a...>
wrote:
> Hi,
>
> At March 26, 2004, 06:53, Geoff Worboys wrote:
>
> >>> /* INSERT INTO FLOAT_ZERO_TEST (PK, DV) VALUES (-0.0, -0.0);
> >>> causes duplicate exception */
>
> >> This *should* word. IEEE floats distiguish between -0 and +0.
> >> I DO consider this a BUG.
>
> > I did not know what to think of this, which is why I left it
> > in there as a comment.
>
> > I've never seen the actual IEEE standard - and whether it says
> > anything about how literals should be interpreted or how +/- 0
> > should be compared.
>
> Here are 2 links that I found on Google:
> http://www.psc.edu/general/software/packages/ieee/ieee.html
>
http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html
>
> They both make a distinction between -0.0 and +0.0, because of the
> sign bit. It is also possible that a compiler doesn't make the
> distinction between them. But, because Firebird's indices are binary
> representations of the values, it might(and mostly) possible that
the
> sign bit is taken into consideration.


I checked this in Delphi 5, and the value '-0.0' is actually stored
with a sign bit of 1 and zeros for the rest. But all comparisons
between this number and the '0' is evaluated to 'true'. Stepping in
the debugger shows a fcomp/fcompp instruction is used for evaluation.
In short, this means that the FPU is not able to distinguish between
the two values. Thus, one would have a hard time making a complete
system support -0.0....;-)