I think the function that converts a float to bigfloat is weird (but not
necessarily broken). Consider
(C1) fpprec : 60;
(D1) 60
(C2) x : float(8/9);
(D2) 0.8888888888888888
(C3) bfloat(x);
Warning: Float to bigfloat conversion of 0.88888888888888884
(D3) 8.88888888888888888888888888888888888888888888888888888888889B-1
Questions:
(1) Is (D3) the bfloat nearest to x? I don't think so. Shouldn't
the nearest big float look something like
8.888888888888888 followed by "fuzz digits" B-1
where the first fuzz digit is less than 5? Instead, Maxima seems to
psychically infer that x started its life as 8/9.
(2) In the warning,
Warning: Float to bigfloat conversion of 0.88888888888888884
why is the last digit 4? I'd expect it to be 8 or 9, but not 4.
(3) Is it possible to do the float to bfloat conversion portably
by extracting the various parts of the float (frational part, exponent,
and sign bit) and bit copy them into a bigfloat?
Here is an alternative float to bigfloat function. The value in (D6)
seems more reasonable to me than does (D3). Yes, I know, this is a
goofy way to convert from a float to a bigfloat.
(C4) float2rational(x) := (
if ?floatp(x) then (
x : ?rational(x),
?numerator(x) / ?denominator(x))
else x)$
(C5) myfloat2bf(x) := bfloat(float2rational(x))$
(C6) myfloat2bf(x);
(D6) 8.88888888888888839545643349993042647838592529296875B-1
(C7)
Maxima version: 5.9.0
Maxima build date: 19:10 2/9/2003
host type: i686-pc-mingw32
lisp-implementation-type: Kyoto Common Lisp
lisp-implementation-version: GCL-2-5.0
Note: Commerical Macsyma gives a value that is identical to (D6).
Barton