float to bfloat



>>>>> "Barton" == Barton Willis <willisb@unk.edu> writes:

    Barton> I think the function that  converts a float to bigfloat is weird (but not
    Barton> necessarily broken). Consider

    Barton> (C1) fpprec : 60;
    Barton> (D1)                                  60
    Barton> (C2) x : float(8/9);
    Barton> (D2)                          0.8888888888888888
    Barton> (C3) bfloat(x);
    Barton> Warning:  Float to bigfloat conversion of 0.88888888888888884
    Barton> (D3)   8.88888888888888888888888888888888888888888888888888888888889B-1

    Barton> Questions:

    Barton> (1)  Is  (D3) the bfloat  nearest  to  x?   I don't think so.  Shouldn't 
    Barton> the nearest  big float look  something like

    Barton>             8.888888888888888 followed by "fuzz digits" B-1

    Barton> where the first fuzz digit is less than 5? Instead, Maxima seems to 
    Barton> psychically infer that x started its life as 8/9. 

Look at floattofp in src/float.lisp.  It calls fixfloat which looks
like to rationalizes the number first before converting it to a
bigfloat.  I agree that there should be fuzz digits, but it is rather
nice to see the bigfloat looks like an obvious extension.

    Barton> (2) In the warning, 

    Barton> Warning:  Float to bigfloat conversion of 0.88888888888888884

    Barton> why is the last digit 4?  I'd expect it to be 8 or 9, but not 4. 

Must be a Lisp printer bug.  cmucl prints it with an 8.

Ray