Bill Page wrote:
> 
> On 24 March 2015 at 10:10, Ralf Hemmecke <[email protected]> wrote:
> >
> > Good!!! I hope, some day Float no longer claims to be a Field.
> >
> 
> Yes, I think this is a closely related problem involving different
> possible definitions of equality.

Actually, Float is messy due to variable precision.  At given
precison floats are supposed to have specified number of
significant bits (by default 68).  However, when precision
is increased then we produce floats which have more (say 200)
bits.  When precision is decreased back to 68 bits the 200 bits values
are considered valid floats.  Somewhat strange conseqence of
this is that if 200 bits floats is exactly representable
as 68 bit float, then exponent fields is larger than in typical
68 float while mantissa have a lot of trailing 0 bits.  So
correct hash function for floats could be obtained by dropping
trailing 0 bits from representation and adjusting exponent.
This would effectively give canonical representation.
Another (equivalent) way it to convert to Fraction(Integer).

So correct equality (and hash) function on Float is not that
hard as my previous comment would suggest.  But correct
_use_ of hash function on floats is different matter: due
to rounding results which would be equal in infinitely
precise arithmetic are likely to differ.  So normal case
is that if we have copy of given number than it is equal
to original.  But if we have numbers which came out from
different computations, then there is significant chance
that they will differ.  So there is question how useful
hashing of floats.  Note that practical search is likely
to use fuzzy comparizons which requires different implementation
than exact search.

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to